Using the same MongoDB cluster on Azure Kubernetes Service (AKS) that you deployed in the previous article with Locust running, you can validate the resiliency of the MongoDB cluster during an AKS node pool upgrade.
In this scenario, you upgrade the AKS cluster to a newer version. Upgrading the cluster makes it unavailable for a short period of time.
Get the current AKS cluster version using the
az aks show
command.az aks show --resource-group $MY_RESOURCE_GROUP_NAME --name $MY_CLUSTER_NAME --query kubernetesVersion
Example output:
"1.30"
Check the available versions for the AKS cluster using the
az aks get-upgrades
command and decide which version you want to upgrade to.az aks get-upgrades --resource-group $MY_RESOURCE_GROUP_NAME --name $MY_CLUSTER_NAME --output table
Example output:
Name ResourceGroup MasterVersion Upgrades ------- -------------------------------- --------------- -------------- default myResourceGroup-rg-chinanorth3 1.30.6 1.31.1, 1.31.2
List the node pools in the AKS cluster using the
az aks nodepool list
command.az aks nodepool list --resource-group $MY_RESOURCE_GROUP_NAME --cluster-name $MY_CLUSTER_NAME --output table
Example output:
Name OsType KubernetesVersion VmSize Count MaxPods ProvisioningState Mode ---------- -------- ------------------- --------------- ------- --------- ------------------- ------ systempool Linux 1.30 Standard_DS4_v2 1 30 Succeeded System mongodbpool Linux 1.30 Standard_DS4_v2 3 30 Succeeded User
Once you decide your target Kubernetes version, you need to first upgrade the AKS control plane using the
az aks upgrade
command. In this example, we upgrade to Kubernetes version 1.31.1.az aks upgrade --resource-group $MY_RESOURCE_GROUP_NAME --name $MY_CLUSTER_NAME --kubernetes-version 1.31.1 --control-plane-only --yes
Upgrade the
mongodbpool
node pool to the newer version using theaz aks nodepool upgrade
command. Make sure that Locust from the previous article is still running so you can validate the resiliency of the MongoDB cluster during the AKS node pool upgrade.az aks nodepool upgrade --resource-group $MY_RESOURCE_GROUP_NAME --cluster-name $MY_CLUSTER_NAME --name mongodbpool --kubernetes-version 1.31.1 --yes
This command takes some time to complete. During this time, nodes of the AKS cluster become unavailable as they are upgraded to the newer version. However, the MongoDB cluster continues to serve the requests without any interruption.
Verify that the MongoDB cluster continues to serve requests by checking the Locust dashboard and the Mongo Express dashboard.
After the upgrade is complete, you can verify the Kubernetes version of the
mongodbpool
node pool using theaz aks nodepool list
command.az aks nodepool list --resource-group $MY_RESOURCE_GROUP_NAME --cluster-name $MY_CLUSTER_NAME --output table
Example output:
Name OsType KubernetesVersion VmSize Count MaxPods ProvisioningState Mode ---------- -------- ------------------- --------------- ------- --------- ------------------- ------ systempool Linux 1.30 Standard_DS4_v2 1 30 Succeeded System mongodbpool Linux 1.31.1 Standard_DS4_v2 3 30 Succeeded User