This commit is contained in:
Brian Redmond 2018-01-25 09:44:01 -05:00
Родитель 8eef913dd1
Коммит ddda0129bf
11 изменённых файлов: 142 добавлений и 101 удалений

Просмотреть файл

@ -21,7 +21,8 @@ The labs are based upon a node.js application that allows for voting on the Just
6. Operational Monitoring and Log Management
7. Application and Infrastructure Scaling
8. Moving your data services to Azure PaaS (CosmosDB)
9. AKS Cluster Upgrading
9. Update and Deploy New Version of Application
10. Upgrade an Azure Kubernetes Service (AKS) cluster
## Advanced Labs (Coming Soon)
1. CI/CD Automation

Просмотреть файл

@ -16,10 +16,10 @@ Labs 1 and 2 require the Jumpbox. The subsequent labs all use the Azure Cloud Sh
Once you have accessed the jumpbox, you must clone the workshop repo to the machine.
* Start with a terminal on the jumpbox
* Clone the Github repo via the command line
1. Start with a terminal on the jumpbox
2. Clone the Github repo via the command line
```bash
```
git clone https://github.com/Azure/blackbelt-aks-hackfest.git
```
@ -29,7 +29,7 @@ Once you have accessed the jumpbox, you must clone the workshop repo to the mach
The underlying data store for the app is [MongoDB](https://www.mongodb.com/ "MongoDB Homepage"). It is already running. We need to import the data for our application.
* Import the data using a terminal session on the jumpbox
1. Import the data using a terminal session on the jumpbox
```bash
cd ~/blackbelt-aks-hackfest/linux-container-workshop/app/db
@ -41,7 +41,7 @@ The underlying data store for the app is [MongoDB](https://www.mongodb.com/ "Mon
The API for the app is written in javascript, running on [Node.js](https://nodejs.org/en/ "Node.js Homepage") and [Express](http://expressjs.com/ "Express Homepage")
* Update dependencies and run app via node in a terminal session on the jumpbox
1. Update dependencies and run app via node in a terminal session on the jumpbox
```bash
cd ~/blackbelt-aks-hackfest/linux-container-workshop/app/api
@ -49,7 +49,7 @@ The API for the app is written in javascript, running on [Node.js](https://nodej
npm install && npm run localmachine
```
* Open a new terminal session on the jumpbox and test the API
2. Open a new terminal session on the jumpbox and test the API
use curl
```bash
@ -61,15 +61,15 @@ The API for the app is written in javascript, running on [Node.js](https://nodej
The web frontend for the app is written in [Vue.js](https://vuejs.org/Vue "Vue.js Homepage"), running on [Node.js](https://nodejs.org/en/ "Node.js Homepage") with [Webpack](https://webpack.js.org/ "Webpack Homepage")
* Open a new terminal session on the jumpbox
* Update dependencies and run app via node
1. Open a new terminal session on the jumpbox
2. Update dependencies and run app via node
```bash
cd ~/blackbelt-aks-hackfest/linux-container-workshop/app/web
npm install && npm run localmachine
```
* Test the web front-end
3. Test the web front-end
The jumpbox has an external DNS name and port 8080 is open. You can browse your running app with a link such as: http://jump-vm-csc4f653357f-q72zm5c4ggcza.eastus.cloudapp.azure.com:8080
@ -80,4 +80,4 @@ The web frontend for the app is written in [Vue.js](https://vuejs.org/Vue "Vue.j
## Clean-up
* Close the web and api apps in the terminal windows by hitting `ctrl-c` in each of the corresponding terminal windows
Close the web and api apps in the terminal windows by hitting `ctrl-c` in each of the corresponding terminal windows

Просмотреть файл

@ -158,7 +158,7 @@ Now that we have container images for our application components, we need to sto
### Create Azure Container Registry instance
1. In the browser, sign in to the Azure portal at https://portal.azure.com
1. In the browser, sign in to the Azure portal at https://portal.azure.com. Your Azure login ID will look something like `odl_user_9294@gbbossteamoutlook.onmicrosoft.com`
2. Click "Create a resource" and select "Azure Container Registry"
3. Provide a name for your registry (this must be unique)
4. Use the existing Resource Group

Просмотреть файл

@ -1,17 +1,26 @@
# Azure Kubernetes Service (AKS) Deployment
## Create AKS cluster through Azure CLI
## Create AKS cluster
1. Open your terminal and login to your Azure subscription using the az cli
1. Login to Azure Portal at http://portal.azure.com. Your Azure login ID will look something like `odl_user_9294@gbbossteamoutlook.onmicrosoft.com`
2. Open the Azure Cloud Shell
![Azure Cloud Shell](img/cloudshell.png "Azure Cloud Shell")
3. The first time Cloud Shell is started will require you to create a storage account. In our lab, you must click `Advanced` and enter an account name and share.
4. Once your cloud shell is started, clone the workshop repo into the cloud shell environment
```
az login
git clone https://github.com/Azure/blackbelt-aks-hackfest.git
```
5. In the cloud shell, you are automatically logged into your Azure subscription. ```az login``` is not required.
2. Verify your subscription is correctly selected as the default
6. Verify your subscription is correctly selected as the default
```
az account list
```
3. Find your RG name
7. Find your RG name
```
az group list
@ -35,22 +44,24 @@
]
# grab the name from the results above and set to a variable
NAME=ODL-aks-v2-gbb-8386
```
3. Create your AKS cluster in the resource group created above with 2 nodes, targeting Kubernetes version 1.7.7
8. Create your AKS cluster in the resource group created above with 2 nodes, targeting Kubernetes version 1.7.7
```
# This command will take a number of minutes to run as it is creating the AKS cluster
az aks create -n $NAME -g $NAME -c 2 -k 1.7.7 --generate-ssh-keys
```
5. Get the Kubernetes config files for your new AKS cluster
9. Get the Kubernetes config files for your new AKS cluster
```
az aks get-credentials -n $NAME -g $NAME
```
6. Verify you have API access to your new AKS cluster
10. Verify you have API access to your new AKS cluster
```
kubectl get nodes
```

Просмотреть файл

@ -2,11 +2,36 @@
## Review/Edit the YAML Config Files
* In VS Code (or vi), open the `helper-files` directory and review the yaml files: `heroes-db.yaml`, `heroes-web-api.yaml`
* Note the environment variables that direct each app to other services.
* Update the yaml file for the proper container image names.
* You will need to replace the `<login server>` with the ACR login server created in Lab 2.
* Repeat this **THREE** times in the heroes yaml files (for the web, api, and db images). Example:
1. In Azure Cloud Shell edit `heroes-db.yaml` using `vi`
```
cd ~/blackbelt-aks-hackfest/linux-container-workshop/helper-files
vi heroes-db.yaml
```
* Review the yaml file and learn about some of the settings
* Update the yaml file for the proper container image name
* You will need to replace the `<login server>` with the ACR login server created in lab 2
* Example:
```
spec:
containers:
- image: mycontainerregistry.azurecr.io/azureworkshop/rating-db:v1
name: heroes-db-cntnr
```
2. In Azure Cloud Shell edit `heroes-web-api.yaml` using `vi`
```
cd ~/blackbelt-aks-hackfest/linux-container-workshop/helper-files
vi heroes-web-api.yaml
```
* Review the yaml file and learn about some of the settings. Note the environment variables that allow the services to connect
* Update the yaml file for the proper container image names.
* You will need to replace the `<login server>` with the ACR login server created in lab 2
> Note: You will update the image name TWICE updating the web and api container images.
* Example:
```
spec:

Просмотреть файл

@ -2,6 +2,8 @@
The Kubernetes dashboard is a web ui that lets you view, monitor, and troubleshoot Kubernetes resources.
> Note: The Kubernetes dashboard is a secured endpoint and can only be accessed using the SSH keys for the cluster. Since cloud shell runs in the browser, it is not possible to tunnel to the dashboard using the steps below.
### Accessing The Dashboard UI
There are multiple ways of accessing Kubernetes dashboard. You can access through kubectl command-line interface or through the master server API. We'll be using kubectl, as it provides a secure connection, that doesn't expose the UI to the internet.

Просмотреть файл

@ -10,116 +10,118 @@ There are a number of monitoring solutions available today. Here is a quick, but
For the purposes of this lab we will be focusing in on Prometheus and using Grafana to provide a visual Dashboard of our Azure Kubernetes Service Cluster.
## Exercise 1 - Install Helm
## Install Helm
We are going to be installing Prometheus and Grafana into our K8s cluster using Helm and Tiller. You can think of Helm as a package manager for Kubernetes with Tiller being the server-side component.
1. Install Helm
* Click [here](https://docs.helm.sh/using_helm/#installing-helm) to install Helm CLI if it is not already installed.
1. In the Azure Cloud Shell, the Helm CLI is already installed
2. Initialize Helm
```bash
helm init
```
3. Validate Helm and Tiller were installed successfully
```bash
helm version
# You should see something like the following as output:
Client: &version.Version{SemVer:"v2.7.2", GitCommit:"8478fb4fc723885b155c924d1c8c410b7a9444e6", GitTreeState:"clean"}
Server: &version.Version{SemVer:"v2.7.2", GitCommit:"8478fb4fc723885b155c924d1c8c410b7a9444e6", GitTreeState:"clean"}
```
```
helm init
```
## Exercise 2 - Install Prometheus using Helm
3. Validate Helm and Tiller were installed successfully
```bash
helm version
# You should see something like the following as output:
Client: &version.Version{SemVer:"v2.7.2", GitCommit:"8478fb4fc723885b155c924d1c8c410b7a9444e6", GitTreeState:"clean"}
Server: &version.Version{SemVer:"v2.7.2", GitCommit:"8478fb4fc723885b155c924d1c8c410b7a9444e6", GitTreeState:"clean"}
```
## Install Prometheus using Helm
Prometheus is a Cloud Native Computing Foundation (CNCF) project used to collect and process metrics. It collects metrics from configured targets, in our case it is a Kubernetes Cluster.
1. Install Prometheus using Helm CLI
* Switch to the `helper-files` directory and view the `prometheus-configforhelm.yaml` file. This configures Helm to install Prometheus with our desired settings.
```bash
cd ~/blackbelt-aks-hackfest/linux-container-workshop/helper-files
# The following command will install Prometheus into the K8s cluster using custom settings.
helm install --name gbbhackprometheus stable/prometheus -f prometheus-configforhelm.yaml
```
Switch to the `helper-files` directory and view the `prometheus-configforhelm.yaml` file. This configures Helm to install Prometheus with our desired settings.
```bash
cd ~/blackbelt-aks-hackfest/linux-container-workshop/helper-files
# The following command will install Prometheus into the K8s cluster using custom settings
helm install --name gbbhackprometheus stable/prometheus -f prometheus-configforhelm.yaml
```
2. Validate that Prometheus was Installed
``` bash
kubectl get pods | grep prometheus
# You should see something like the following as output:
gbbhackprometheus-prometheus-kube-state-metrics-5b9f4d9d9-vctrx 1/1 Running 0 3m
gbbhackprometheus-prometheus-node-exporter-v6frn 1/1 Running 0 3m
gbbhackprometheus-prometheus-server-54f5bcb797-sbzsp 2/2 Running 0 3m
```
``` bash
kubectl get pods | grep prometheus
# You should see something like the following as output:
gbbhackprometheus-prometheus-kube-state-metrics-5b9f4d9d9-vctrx 1/1 Running 0 3m
gbbhackprometheus-prometheus-node-exporter-v6frn 1/1 Running 0 3m
gbbhackprometheus-prometheus-server-54f5bcb797-sbzsp 2/2 Running 0 3m
```
```bash
kubectl get svc | grep prometheus
# You should see something like the following as output:
gbbhackprometheus-prometheus-kube-state-metrics ClusterIP None <none> 80/TCP 3m
gbbhackprometheus-prometheus-node-exporter ClusterIP None <none> 9100/TCP 3m
gbbhackprometheus-prometheus-server LoadBalancer 10.0.212.145 52.168.100.25 9090:32340/TCP 3m
```
```bash
kubectl get svc | grep prometheus
# You should see something like the following as output:
gbbhackprometheus-prometheus-kube-state-metrics ClusterIP None <none> 80/TCP 3m
gbbhackprometheus-prometheus-node-exporter ClusterIP None <none> 9100/TCP 3m
gbbhackprometheus-prometheus-server LoadBalancer 10.0.212.145 52.168.100.25 9090:32340/TCP 3m
```
## Exercise 3 - Install Grafana
## Install Grafana
Grafana is a dashboard visualization tool that can use all kinds of data sources. In our case, Prometheus will be used as the data source.
1. Install Grafana using Helm CLI
* The following command will install Grafana into the K8s cluster with a few custom settings to make it easier to access.
```bash
# We are setting the default username and password to **admin** to make it easier to remember.
# We are also setting the service type to **LoadBalancer** to expose the service outside of the cluster and make it accessible via the Internet.
helm install --name gbbhackgrafana stable/grafana --set server.service.type=LoadBalancer,server.adminUser=admin,server.adminPassword=admin
```
The following command will install Grafana into the K8s cluster with a few custom settings to make it easier to access.
* We are setting the default username and password to **admin** to make it easier to remember
* We are also setting the service type to **LoadBalancer** to expose the service outside of the cluster and make it accessible via the Internet
```bash
helm install --name gbbhackgrafana stable/grafana --set server.service.type=LoadBalancer,server.adminUser=admin,server.adminPassword=admin
```
2. Validate that Grafana was Installed
```bash
kubectl get pods | grep grafana
# You should see something like the following as output:
hgrafana-grafana-855db78dc4-pnzth 1/1 Running 0 2h
```
```bash
kubectl get pods | grep grafana
# You should see something like the following as output:
hgrafana-grafana-855db78dc4-pnzth 1/1 Running 0 2h
```
```bash
kubectl get svc | grep grafana
# You should see something like the following as output, take note of the **EXTERNAL-IP column**:
khgrafana-grafana LoadBalancer 10.0.163.226 "52.226.75.38" 80:31476/TCP 2h
```
```bash
kubectl get svc | grep grafana
# You should see something like the following as output, take note of the **EXTERNAL-IP column**:
khgrafana-grafana LoadBalancer 10.0.163.226 "52.226.75.38" 80:31476/TCP 2h
```
3. Test Grafana UI Comes Up
Use the EXTERNAL-IP value from the previous step and put that into your browser:
* eg. http://52.226.75.38, EXTERNAL-IP column from above. You should see something like the following come up, be patient it will take a moment or two:
* eg. http://52.226.75.38, EXTERNAL-IP column from above. You should see something like the following come up, be patient it will take a moment or two:
![](img/8-grafana_default.png)
![](img/8-grafana_default.png)
## Exercise 4 - Setting up Grafana
## Setting up Grafana
1. Log into Grafana Dashboard using **admin** for the username and password
* You should see something like the following:
* You should see something like the following:
![](img/8-grafana_loggedin.png)
![](img/8-grafana_loggedin.png)
2. Add Prometheus as a Data Source
* If you recall from above, we exposed a number of K8s services, one of those services was the Prometheus Server. We are going to use that Service endpoint in our Data Service configuration. The Add Data Source screen should look something like the below screen shot.
* If you recall from above, we exposed a number of K8s services, one of those services was the Prometheus Server. We are going to use that Service endpoint in our Data Service configuration. The Add Data Source screen should look something like the below screen shot.
> Use `http://gbbhackprometheus-prometheus-server:9090` for the URL in the HTTP settings.
> Use `http://gbbhackprometheus-prometheus-server:9090` for the URL in the HTTP settings.
![](img/8-grafana_datasource.png)
![](img/8-grafana_datasource.png)
3. Validate Prometheus Data Source
* Once you have filled in the values similar to the screenshot above, click the **Add** button and ensure no errors come back.
* Once you have filled in the values similar to the screenshot above, click the **Add** button and ensure no errors come back.
4. Add K8s Monitoring Dashboard to Grafana
* After the datasource has been added, it is now time to add a dashboard. Grafana dashboards can be shared on Grafana.com. Go to import dashboards viam the menu in the top left.
* After the datasource has been added, it is now time to add a dashboard. Grafana dashboards can be shared on Grafana.com. Go to import dashboards viam the menu in the top left.
![](img/8-grafana_dashboardimport.png)
![](img/8-grafana_dashboardimport.png)
* Click on the **Upload File** button and browse to the `grafana-dashboard.json` in the `linux-container-workshop/helper-files` directory. You can also paste the contents of the json into the text box.
* Click on the **Upload File** button and browse to the `grafana-dashboard.json` in the `linux-container-workshop/helper-files` directory. You can also paste the contents of the json into the text box.
![](img/8-grafana_dashboardid.png)
![](img/8-grafana_dashboardid.png)
* Set the datasource dropdown to the "AKSPrometheus" that was created in the previous step.
* Set the datasource dropdown to the "AKSPrometheus" that was created in the previous step.
![](img/8-grafana_dashboardsave.png)
![](img/8-grafana_dashboardsave.png)
* Click the **Import** button.
![](img/8-grafana_k8sdashboard.png)
* Click the **Import** button.
![](img/8-grafana_k8sdashboard.png)
You should now have Prometheus and Grafana running in your Azure Kubernetes Service cluster and be able to see the Grafana Dashboard.
You should now have Prometheus and Grafana running in your Azure Kubernetes Service cluster and be able to see the Grafana Dashboard.

Просмотреть файл

@ -2,7 +2,7 @@
Imagine a scenario where your realize that your existing cluster is at capacity and you need to scale it out to add more nodes in order to increase capacity and be able to deploy more PODS.
## Exercise 1 - Scale Application
## Scale Application
1. Check to see current number of pods running via Grafana Dashboard.
* Go to the same Grafana Dashboard from exercise 8 and look at the **Pods Running Count** section. You will see the total count of Pods and the various phases they are in.
@ -43,7 +43,7 @@ heroes-web-3683626428-zxp2s 1/1 Runn
![](img/9-grafana_podspending.png)
## Exercise 2 - Scale K8s Cluster
## Scale K8s Cluster
1. Check to see number of current nodes running.
```bash
kubectl get nodes

Просмотреть файл

@ -1,4 +1,4 @@
# Upgrade an Azure Container Service (AKS) cluster
# Upgrade an Azure Kubernetes Service (AKS) cluster
Azure Container Service (AKS) makes it easy to perform common management tasks including upgrading Kubernetes clusters.

Двоичные данные
linux-container-workshop/hol-content/img/cloudshell.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 249 KiB