Azure Hands-On Lab - Patch and upgrade an AKS Cluster
Azure Learning Path for Cloud and DevOps Engineers
📝Introduction
In this hands-on lab, we will apply patch updates and upgrade the AKS cluster to the latest supported Kubernetes version.
Learning objectives
In this module, you'll learn how to:
Understand what Kubernetes versions AKS supports.
Upgrade your existing AKS cluster components to the latest supported Kubernetes version.
Upgrade your AKS clusters in production environments using a Blue/Green deployment.
📝Log in to the Azure Management Console
Using your credentials, make sure you're using the right Region. In my case, I am using the region southcentralus
in my Cloud Playground Sandbox.
📌Note: You can also use the VSCode tool or from your local Terminal to connect to Azure CLI
More information on how to set it up is at the link.
📝Prerequisites:
Update to PowerShell 5.1, if needed.
Install .NET Framework 4.7.2 or later.
Visual Code
Web Browser (Chrome, Edge)
Azure CLI installed
Azure subscription
Docker installed
📝Setting an Azure Storage Account to Load Bash or PowerShell
- Click the Cloud Shell icon
(>_)
at the top of the page.
- Click PowerShell.
- Click Show Advanced Settings. Use the combo box under Cloud Shell region to select the Region. Under Resource Group and Storage account(It's a globally unique name), enter a name for both. In the box under File Share, enter a name. Click ***Create storage (***if you don't have any yet).
📝Create an AKS cluster
In Azure Cloud Shell, create a resource group using the
az group create
command.az group create -l <location> -n <ResourceGroupName>
Check the current list of Kubernetes versions that AKS supports using the
az aks get-versions
command.az aks get-versions -l <location> -o table
Find the oldest supported Kubernetes version from the list and store it in a KV variable.
KV=1.27.7
Get your resource group name and store it inside a variable named RG.
az group list -o table RG=<ResourceGroupName>
Create an AKS cluster using the
az aks create
command, but before storing the name of the cluster inside a variable named CLUSTERNAME.CLUSTERNAME=<AKSClusterName> az aks create -n $CLUSTERNAME -g $RG --kubernetes-version $KV --node-vm-size Standard_D2s_v3 --node-count 2 --generate-ssh-keys
📝Upgrade the AKS cluster
- Check for available cluster upgrades using the
az aks get-upgrades
command.
az aks get-upgrades -n $CLUSTERNAME -g $RG -o table
You'll see the versions available for upgrades, which are the next three supported Kubernetes versions from the current AKS cluster version.
Try to immediately upgrade to the latest supported Kubernetes version using the
az aks upgrade
command and replace[latest-version]
with the latest Kubernetes version from the previous step.az aks upgrade -n $CLUSTERNAME -g $RG -k [latest-version]
Confirm the upgrade using the
az aks show
command.az aks show -n $CLUSTERNAME -g $RG -o table
However, you might get an error message because you can't skip minor versions when upgrading your AKS cluster. This means depends on the running version you're using, for example, version 1.26.x maybe you can't immediately upgrade to version 1.28.x and above. In this case, you can skip patch version upgrades within a minor version and follow the next steps.
📝Apply patches updates
Apply patch updates to the AKS cluster using the
az aks upgrade
command and replace[next-patch-version]
with the next patch version from the previous section.az aks upgrade -n $CLUSTERNAME -g $RG --no-wait -k [next-patch-version]
📌Note: It's possible to apply upgrades only to the control plane in the AKS cluster or only to the nodes in the AKS cluster by including the optional parameters
--control-plane-only
or--node-image-only
when running the upgrade command. If the optional parameters aren't included, both the control plane and nodes in the AKS cluster are upgraded.Confirm the patch upgrade using the
az aks show
command.az aks show -n $CLUSTERNAME -g $RG -o table
📝Upgrade to the next minor version
Upgrade the AKS cluster to the next supported Kubernetes minor version using the
az aks upgrade
command and replace[next-minor-version]
with the next minor version from the previous section.az aks upgrade -n $CLUSTERNAME -g $RG --no-wait -k [next-minor-version]
Confirm the upgrade using the
az aks show
command.az aks show -n $CLUSTERNAME -g $RG -o table
Upgrade the cluster to the latest stable Kubernetes version AKS supports using the
az aks upgrade
command and replace[latest-stable-version]
with the latest stable version from the previous section.az aks upgrade -n $CLUSTERNAME -g $RG --no-wait -k [latest-stable-version]
Confirm the upgrade using the
az aks show
command.az aks show -n $CLUSTERNAME -g $RG -o table
📌Note - At the end of each hands-on Lab, always clean up all resources previously created to avoid being charged.
Congratulations — you have completed this hands-on lab covering the basics of applying patch updates and upgrading the AKS cluster to the latest supported Kubernetes version.
Thank you for reading. I hope you understood and learned something helpful from my blog.
Please follow me on Cloud&DevOpsLearn and LinkedIn, franciscojblsouza