You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
title: Kubernetes on Azure tutorial - Update application
3
-
description: AKS tutorial - Update Application
2
+
title: Kubernetes on Azure tutorial - Update an application
3
+
description: In this Azure Kubernetes Service (AKS) tutorial, you learn how to update an existing application deployment to AKS with a new version of the application code.
4
4
services: container-service
5
5
author: iainfoulds
6
6
manager: jeconnoc
7
7
8
8
ms.service: container-service
9
9
ms.topic: tutorial
10
-
ms.date: 02/24/2018
10
+
ms.date: 08/14/2018
11
11
ms.author: iainfou
12
12
ms.custom: mvc
13
+
14
+
#Customer intent: As a developer, I want to learn how to update an existing application deployment in an Azure Kubernetes Service (AKS) cluster so that I can maintain the application lifecycle.
13
15
---
14
16
15
17
# Tutorial: Update an application in Azure Kubernetes Service (AKS)
16
18
17
19
After an application has been deployed in Kubernetes, it can be updated by specifying a new container image or image version. When doing so, the update is staged so that only a portion of the deployment is concurrently updated. This staged update enables the application to keep running during the update. It also provides a rollback mechanism if a deployment failure occurs.
18
20
19
-
In this tutorial, part six of seven, the sample Azure Vote app is updated. Tasks that you complete include:
21
+
In this tutorial, part six of seven, the sample Azure Vote app is updated. You learn how to:
20
22
21
23
> [!div class="checklist"]
22
-
> *Updating the front-end application code
23
-
> *Creating an updated container image
24
-
> *Pushing the container image to Azure Container Registry
25
-
> *Deploying the updated container image
24
+
> *Update the front-end application code
25
+
> *Create an updated container image
26
+
> *Push the container image to Azure Container Registry
27
+
> *Deploy the updated container image
26
28
27
29
## Before you begin
28
30
29
-
In previous tutorials, an application was packaged into a container image, the image uploaded to Azure Container Registry, and a Kubernetes cluster created. The application was then run on the Kubernetes cluster.
30
-
31
-
An application repository was also cloned which includes the application source code, and a pre-created Docker Compose file used in this tutorial. Verify that you have created a clone of the repo, and that you have changed directories into the cloned directory. Inside is a directory named `azure-vote` and a file named `docker-compose.yaml`.
31
+
In previous tutorials, an application was packaged into a container image, the image uploaded to Azure Container Registry (ACR), and a Kubernetes cluster created. The application was then run on the Kubernetes cluster.
32
32
33
-
If you haven't completed these steps, and want to follow along, return to [Tutorial 1 – Create container images][aks-tutorial-prepare-app].
33
+
An application repository was also cloned that includes the application source code, and a pre-created Docker Compose file used in this tutorial. Verify that you have created a clone of the repo, and that you have changed directories into the cloned directory. If you haven't completed these steps, and want to follow along, return to [Tutorial 1 – Create container images][aks-tutorial-prepare-app].
34
34
35
-
## Update application
35
+
This tutorial requires that you are running the Azure CLI version 2.0.44 or later. Run `az --version` to find the version. If you need to install or upgrade, see [Install Azure CLI][azure-cli-install].
36
36
37
-
For this tutorial, a change is made to the application, and the updated application deployed to the Kubernetes cluster.
37
+
## Update an application
38
38
39
-
The application source code can be found inside of the `azure-vote` directory. Open the `config_file.cfg` file with any code or text editor. In this example `vi` is used.
39
+
Let's make a change to the sample application, then update the version already deployed to your AKS cluster. The sample application source code can be found inside of the *azure-vote* directory. Open the *config_file.cfg* file with an editor, such as `vi`:
40
40
41
41
```console
42
42
vi azure-vote/azure-vote/config_file.cfg
43
43
```
44
44
45
-
Change the values for `VOTE1VALUE` and `VOTE2VALUE`, and then save the file.
45
+
Change the values for *VOTE1VALUE* and *VOTE2VALUE* to different colors. The following example shows the updated color values:
46
46
47
-
```console
47
+
```
48
48
# UI Configurations
49
49
TITLE = 'Azure Voting App'
50
50
VOTE1VALUE = 'Blue'
@@ -54,112 +54,109 @@ SHOWHOST = 'false'
54
54
55
55
Save and close the file.
56
56
57
-
## Update container image
57
+
## Update the container image
58
58
59
-
Use [docker-compose][docker-compose] to re-create the front-end image and run the updated application. The `--build` argument is used to instruct Docker Compose to re-create the application image.
59
+
To re-create the front-end image and test the updated application, use [docker-compose][docker-compose]. The `--build` argument is used to instruct Docker Compose to re-create the application image:
60
60
61
61
```console
62
62
docker-compose up --build -d
63
63
```
64
64
65
-
## Test application locally
65
+
## Test the application locally
66
66
67
-
Browse to http://localhost:8080 to see the updated application.
67
+
To verify that the updated container image shows your changes, open a local web browser to http://localhost:8080.
68
68
69
69

70
70
71
-
## Tag and push images
71
+
The updated color values provided in the *config_file.cfg* file are displayed on your running application.
72
72
73
-
Tag the `azure-vote-front` image with the loginServer of the container registry.
73
+
## Tag and push the image
74
74
75
-
Get the login server name with the [az acr list](/cli/azure/acr#az-acr-list) command.
75
+
To correctly use the updated image, tag the *azure-vote-front* image with the login server name of your ACR registry. Get the login server name with the [az acr list](/cli/azure/acr#az_acr_list) command:
76
76
77
77
```azurecli
78
78
az acr list --resource-group myResourceGroup --query "[].{acrLoginServer:loginServer}" --output table
79
79
```
80
80
81
-
Use [docker tag][docker-tag] to tag the image. Replace `<acrLoginServer>` with your Azure Container Registry login server name or public registry hostname. Also notice that the image version is updated to `v2`.
81
+
Use [docker tag][docker-tag] to tag the image. Replace `<acrLoginServer>` with your ACR login server name or public registry hostname, and update the image version to *:v2* as follows:
82
82
83
83
```console
84
84
docker tag azure-vote-front <acrLoginServer>/azure-vote-front:v2
85
85
```
86
86
87
-
Use [docker push][docker-push] to upload the image to your registry. Replace `<acrLoginServer>` with your Azure Container Registry login server name. If you experience issues pushing to your ACR registry, ensure that you have run the [az acr login][az-acr-login] command.
87
+
Now use [docker push][docker-push] to upload the image to your registry. Replace `<acrLoginServer>` with your ACR login server name. If you experience issues pushing to your ACR registry, ensure that you have run the [az acr login][az-acr-login] command.
88
88
89
89
```console
90
90
docker push <acrLoginServer>/azure-vote-front:v2
91
91
```
92
92
93
-
## Deploy update application
93
+
## Deploy the updated application
94
94
95
-
To ensure maximum uptime, multiple instances of the application pod must be running. Verify this configuration with the [kubectl get pod][kubectl-get] command.
95
+
To ensure maximum uptime, multiple instances of the application pod must be running. Verify the number of running front-end instances with the [kubectl get pods][kubectl-get] command:
To update the application, use the [kubectl set][kubectl-set] command. Update `<acrLoginServer>` with the login server or host name of your container registry.
113
+
To update the application, use the [kubectl set][kubectl-set] command. Update `<acrLoginServer>` with the login server or host name of your container registry, and specify the *v2* application version:
119
114
120
-
```azurecli
115
+
```console
121
116
kubectl set image deployment azure-vote-front azure-vote-front=<acrLoginServer>/azure-vote-front:v2
122
117
```
123
118
124
119
To monitor the deployment, use the [kubectl get pod][kubectl-get] command. As the updated application is deployed, your pods are terminated and re-created with the new container image.
125
120
126
-
```azurecli
127
-
kubectl get pod
121
+
```console
122
+
kubectl get pods
128
123
```
129
124
130
-
Output:
125
+
The following example output shows pods terminating and new instances running as the deployment progresses:
title: Kubernetes on Azure tutorial - Deploy Application
3
-
description: AKS tutorial - Deploy Application
2
+
title: Kubernetes on Azure tutorial - Deploy an application
3
+
description: In this Azure Kubernetes Service (AKS) tutorial, you deploy a multi-container application to your cluster using a custom image stored in Azure Container Registry.
4
4
services: container-service
5
5
author: iainfoulds
6
6
manager: jeconnoc
7
7
8
8
ms.service: container-service
9
9
ms.topic: tutorial
10
-
ms.date: 02/22/2018
10
+
ms.date: 08/14/2018
11
11
ms.author: iainfou
12
12
ms.custom: mvc
13
+
14
+
#Customer intent: As a developer, I want to learn how to deploy apps to an Azure Kubernetes Service (AKS) cluster so that I can deploy and run my own applications.
13
15
---
14
16
15
17
# Tutorial: Run applications in Azure Kubernetes Service (AKS)
16
18
17
-
In this tutorial, part four of seven, a sample application is deployed into a Kubernetes cluster. Steps completed include:
19
+
Kubernetes provides a distributed platform for containerized applications. You build and deploy your own applications and services into a Kubernetes cluster, and let the cluster manage the availability and connectivity. In this tutorial, part four of seven, a sample application is deployed into a Kubernetes cluster. You learn how to:
18
20
19
21
> [!div class="checklist"]
20
-
> * Update Kubernetes manifest files
21
-
> * Run application in Kubernetes
22
+
> * Update a Kubernetes manifest files
23
+
> * Run an application in Kubernetes
22
24
> * Test the application
23
25
24
26
In subsequent tutorials, this application is scaled out and updated.
@@ -29,35 +31,35 @@ This tutorial assumes a basic understanding of Kubernetes concepts, for detailed
29
31
30
32
In previous tutorials, an application was packaged into a container image, this image was uploaded to Azure Container Registry, and a Kubernetes cluster was created.
31
33
32
-
To complete this tutorial, you need the pre-created `azure-vote-all-in-one-redis.yaml` Kubernetes manifest file. This file was downloaded with the application source code in a previous tutorial. Verify that you have cloned the repo, and that you have changed directories into the cloned repo.
34
+
To complete this tutorial, you need the pre-created `azure-vote-all-in-one-redis.yaml` Kubernetes manifest file. This file was downloaded with the application source code in a previous tutorial. Verify that you have cloned the repo, and that you have changed directories into the cloned repo. If you have not done these steps, and would like to follow along, return to [Tutorial 1 – Create container images][aks-tutorial-prepare-app].
33
35
34
-
If you have not done these steps, and would like to follow along, return to [Tutorial 1 – Create container images][aks-tutorial-prepare-app].
36
+
This tutorial requires that you are running the Azure CLI version 2.0.44 or later. Run `az --version`to find the version. If you need to install or upgrade, see [Install Azure CLI][azure-cli-install].
35
37
36
-
## Update manifest file
38
+
## Update the manifest file
37
39
38
-
In this tutorial, Azure Container Registry (ACR) has been used to store a container image. Before running the application, the ACR login server name needs to be updated in the Kubernetes manifest file.
40
+
In these tutorials, an Azure Container Registry (ACR) instance stores the container image for the sample application. To deploy the application, you must update the image name in the Kubernetes manifest file to include the ACR login server name.
39
41
40
-
Get the ACR login server name with the [az acr list][az-acr-list] command.
42
+
Get the ACR login server name using the [az acr list][az-acr-list] command as follows:
41
43
42
44
```azurecli
43
45
az acr list --resource-group myResourceGroup --query "[].{acrLoginServer:loginServer}" --output table
44
46
```
45
47
46
-
The manifest file has been pre-created with a login server name of `microsoft`. Open the file with any text editor. In this example, the file is opened with `nano`.
48
+
The sample manifest file from the git repo cloned in the first tutorial uses the login server name of *microsoft*. Open this manifest file with a text editor, such as `vi`:
47
49
48
50
```console
49
-
nano azure-vote-all-in-one-redis.yaml
51
+
vi azure-vote-all-in-one-redis.yaml
50
52
```
51
53
52
-
Replace `microsoft` with the ACR login server name. This value is found on line **47** of the manifest file.
54
+
Replace *microsoft* with your ACR login server name. The image name is found on line 47 of the manifest file. The following example shows the default image name:
53
55
54
56
```yaml
55
57
containers:
56
58
- name: azure-vote-front
57
59
image: microsoft/azure-vote-front:v1
58
60
```
59
61
60
-
The above code then becomes.
62
+
Provide your own ACR login server name so that your manifest file looks like the following example:
61
63
62
64
```yaml
63
65
containers:
@@ -67,63 +69,61 @@ containers:
67
69
68
70
Save and close the file.
69
71
70
-
## Deploy application
72
+
## Deploy the application
71
73
72
-
Use the [kubectl apply][kubectl-apply] command to run the application. This command parses the manifest file and creates the defined Kubernetes objects.
74
+
To deploy your application, use the [kubectl apply][kubectl-apply] command. This command parses the manifest file and creates the defined Kubernetes objects. Specify the sample manifest file, as shown in the following example:
73
75
74
-
```azurecli
76
+
```console
75
77
kubectl apply -f azure-vote-all-in-one-redis.yaml
76
78
```
77
79
78
-
Output:
80
+
The Kubernetes objects are created within the cluster, as shown in the following example:
A [Kubernetes service][kubernetes-service] is created which exposes the application to the internet. This process can take a few minutes.
91
+
## Test the application
90
92
91
-
To monitor progress, use the [kubectl get service][kubectl-get] command with the `--watch` argument.
93
+
A [Kubernetes service][kubernetes-service] is created which exposes the application to the internet. This process can take a few minutes. To monitor progress, use the [kubectl get service][kubectl-get] command with the `--watch` argument:
92
94
93
-
```azurecli
95
+
```console
94
96
kubectl get service azure-vote-front --watch
95
97
```
96
98
97
-
Initially the *EXTERNAL-IP* for the *azure-vote-front* service appears as *pending*.
99
+
The *EXTERNAL-IP* for the *azure-vote-front* service initially appears as *pending*, as shown in the following example:
Once the *EXTERNAL-IP* address has changed from *pending* to an *IP address*, use `CTRL-C` to stop the kubectl watch process.
105
+
When the *EXTERNAL-IP* address changes from *pending* to an actual public IP address, use `CTRL-C` to stop the kubectl watch process. The following example shows a public IP address is now assigned:
To see the application, browse to the external IP address.
111
+
To see the application in action, open a web browser to the external IP address.
110
112
111
113

112
114
113
-
If the application did not load, it might be due to an authorization problem with your image registry.
114
-
115
-
Please follow these steps to [allow access via a Kubernetes secret](https://docs.microsoft.com/azure/container-registry/container-registry-auth-aks#access-with-kubernetes-secret).
115
+
If the application did not load, it might be due to an authorization problem with your image registry. To view the status of your containers, use the `kubectl get pods` command. If the container images cannot be pulled, see [allow access to Container Registry with a Kubernetes secret](https://docs.microsoft.com/azure/container-registry/container-registry-auth-aks#access-with-kubernetes-secret).
116
116
117
117
## Next steps
118
118
119
-
In this tutorial, the Azure vote application was deployed to a Kubernetes cluster in AKS. Tasks completed include:
119
+
In this tutorial, the Azure vote application was deployed to a Kubernetes cluster in AKS. You learned how to:
120
120
121
121
> [!div class="checklist"]
122
-
> *Download Kubernetes manifest files
123
-
> * Run the application in Kubernetes
124
-
> *Tested the application
122
+
> *Update a Kubernetes manifest files
123
+
> * Run an application in Kubernetes
124
+
> *Test the application
125
125
126
-
Advance to the next tutorial to learn about scaling both a Kubernetes application and the underlying Kubernetes infrastructure.
126
+
Advance to the next tutorial to learn how to scale a Kubernetes application and the underlying Kubernetes infrastructure.
127
127
128
128
> [!div class="nextstepaction"]
129
129
> [Scale Kubernetes application and infrastructure][aks-tutorial-scale]
@@ -139,3 +139,4 @@ Advance to the next tutorial to learn about scaling both a Kubernetes applicatio
0 commit comments