Navigate back to the homepage

Simple guide to upgrading AKS Clusters on Azure

Alex Woodhead
September 27th, 2020 · 1 min read

Upgrading you AKS cluster on Azure is a very simple process. The following commands used were all taken from the documentation

Determine which version you can upgrade to

Firstly, you need to identify the versions that are available to your cluster within the region that it is deployed within:

1C:\> az aks get-versions --location uksouth --output table

This will output the available versions that can be upgraded to in the region that your AKS cluster is hosted within:

1KubernetesVersion Upgrades
2------------------- -----------------------
31.18.8 None available
41.18.6 1.18.8
51.17.9 1.18.6, 1.18.8
61.17.7 1.17.9, 1.18.6, 1.18.8
71.16.13 1.17.7, 1.17.9
81.16.10 1.16.13, 1.17.7, 1.17.9
9C:\>

You are only able to upgrade minor versions at a time with AKS, but if you have fallen outside of the supported version the version you can upgrade to will be the minimum, supported version on AKS. There may be a need to upgrade multiple times to arrive at your destination version.

Next run a command to determine which is the next version(s) you can upgrade to from you current version:

1C:\> az aks get-upgrades --resource-group *** --name ***

This will output the versions that both your control plane and nodes are running against along with the version they can be upgraded to:

1{
2 "agentPoolProfiles": [
3 {
4 "kubernetesVersion": "1.13.10",
5 "name": null,
6 "osType": "Linux",
7 "upgrades": [
8 {
9 "isPreview": null,
10 "kubernetesVersion": "1.16.10"
11 },
12 {
13 "isPreview": null,
14 "kubernetesVersion": "1.16.13"
15 }
16 ]
17 }
18 ],
19 "controlPlaneProfile": {
20 "kubernetesVersion": "1.13.10",
21 "name": null,
22 "osType": "Linux",
23 "upgrades": [
24 {
25 "isPreview": null,
26 "kubernetesVersion": "1.16.10"
27 },
28 {
29 "isPreview": null,
30 "kubernetesVersion": "1.16.13"
31 }
32 ]
33 },
34 "id": "/subscriptions/***/resourcegroups/***/providers/Microsoft.ContainerService/...",
35 "name": "default",
36 "resourceGroup": "***",
37 "type": "Microsoft.ContainerService/managedClusters/upgradeprofiles"
38}

Upgrade you Cluster

Next step is to execute the command to upgrade to a specific version:

1C:\> az aks upgrade --resource-group *** --name *** --kubernetes-version 1.16.13

This will warn you about the availability of your cluster, which you will need to acknowledge:

1Kubernetes may be unavailable during cluster upgrades.
2Are you sure you want to perform this operation? (y/n): y

When I ran this command for the first time, I received the following warning:

1Operation failed with status: 'Bad Request'. Details: Unable to retrieve log analytics workspace. Resource ID: /subscriptions/***/resourcegroups/defaultresourcegroup-suk/providers/microsoft.operationalinsights/workspaces/***-law.
2If resource is intentionally deleted to stop monitoring, please also disable monitoring addon by following doc: https://aka.ms/aks-disable-monitoring-addon.
3If resource is deleted by mistake, please re-create it by following doc: https://aka.ms/new-log-analytics, and enable new workspace resource id by following doc: https://aka.ms/aks-enable-addons

This was resolved by temporarily removing the monitoring addon with the following command:

1C:\> az aks disable-addons -a monitoring -n *** -g ***

After resolving this issue, I re-ran the command to upgrade the cluster, this time I saw a progress message:

1C:\> az aks upgrade --resource-group *** --name *** --kubernetes-version 1.16.13
2Kubernetes may be unavailable during cluster upgrades.
3Are you sure you want to perform this operation? (y/n): y
4 - Running ..

Eventually this outputted a json result of the state of the cluster following the upgrade:

1{
2 "aadProfile": null,
3 "addonProfiles": {
4 "KubeDashboard": {
5 "config": null,
6 "enabled": true,
7 "identity": null
8 },
9 "httpApplicationRouting": {
10 "config": null,
11 "enabled": false,
12 "identity": null
13 },
14 "omsagent": {
15 "config": null,
16 "enabled": false,
17 "identity": null
18 }
19 },
20 "agentPoolProfiles": [
21 {
22 "availabilityZones": null,
23 "count": 3,
24 "enableAutoScaling": null,
25 "enableNodePublicIp": null,
26 "maxCount": null,
27 "maxPods": 30,
28 "minCount": null,
29 "mode": "User",
30 "name": "agentpool",
31 "nodeLabels": null,
32 "nodeTaints": null,
33 "orchestratorVersion": "1.16.13",
34 "osDiskSizeGb": 100,
35 "osType": "Linux",
36 "provisioningState": "Succeeded",
37 "scaleSetEvictionPolicy": null,
38 "scaleSetPriority": null,
39 "spotMaxPrice": null,
40 "tags": null,
41 "type": "AvailabilitySet",
42 "vmSize": "Standard_D4s_v3",
43 "vnetSubnetId": "/subscriptions/***/resourceGroups/***/providers/Microsoft..."
44 }
45 ],
46 "apiServerAccessProfile": null,
47 "autoScalerProfile": null,
48 "diskEncryptionSetId": null,
49 "dnsPrefix": "***",
50 "enablePodSecurityPolicy": null,
51 "enableRbac": false,
52 "fqdn": "***",
53 "id": "/subscriptions/***/resourcegroups/***/providers/Microsoft.ContainerService/...",
54 "identity": null,
55 "identityProfile": null,
56 "kubernetesVersion": "1.16.13",
57 "linuxProfile": null,
58 "location": "uksouth",
59 "maxAgentPools": 1,
60 "name": "***",
61 "networkProfile": {
62 "dnsServiceIp": "***",
63 "dockerBridgeCidr": "***",
64 "loadBalancerProfile": null,
65 "loadBalancerSku": "Basic",
66 "networkMode": null,
67 "networkPlugin": "azure",
68 "networkPolicy": null,
69 "outboundType": "loadBalancer",
70 "podCidr": null,
71 "serviceCidr": "***"
72 },
73 "nodeResourceGroup": "***",
74 "privateFqdn": null,
75 "provisioningState": "Succeeded",
76 "resourceGroup": "***",
77 "servicePrincipalProfile": {
78 "clientId": "***",
79 "secret": null
80 },
81 "sku": null,
82 "tags": {
83 "environment": "sit"
84 },
85 "type": "Microsoft.ContainerService/ManagedClusters",
86 "windowsProfile": null
87}
88C:\>

Finally, I was able to verify that I had got to the final version that was supported on AKS at the time, verifying with the previous command to check for upgrades, that there were no further upgrades available:

1C:\> az aks get-upgrades --resource-group *** --name ***
2{
3 "agentPoolProfiles": [
4 {
5 "kubernetesVersion": "1.18.8",
6 "name": null,
7 "osType": "Linux",
8 "upgrades": null
9 }
10 ],
11 "controlPlaneProfile": {
12 "kubernetesVersion": "1.18.8",
13 "name": null,
14 "osType": "Linux",
15 "upgrades": null
16 },
17 "id": "/subscriptions/***/resourcegroups/***/providers/Microsoft.ContainerService...",
18 "name": "default",
19 "resourceGroup": "***",
20 "type": "Microsoft.ContainerService/managedClusters/upgradeprofiles"
21}
22C:\>

More articles from Alex Woodhead

Your job won't fix your career

Warning to the 9-5 developers out there. Don't rely on your job to provide you with the experience to further your career.

April 1st, 2020 · 2 min read

Azure App Service - Best Practices - Health Checks

How to configure Azure App Service Health Checks and why you should do so in your production application

July 7th, 2021 · 2 min read
© 2020–2021 Alex Woodhead
Link to $https://twitter.com/woodheadioLink to $https://github.com/woodheadioLink to $https://www.linkedin.com/in/woodheadio/