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.
Upgrade the AKS cluster
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 showcommand.az aks show --resource-group $MY_RESOURCE_GROUP_NAME --name $MY_CLUSTER_NAME --query kubernetesVersionExample output:
"1.30"Check the available versions for the AKS cluster using the
az aks get-upgradescommand and decide which version you want to upgrade to.az aks get-upgrades --resource-group $MY_RESOURCE_GROUP_NAME --name $MY_CLUSTER_NAME --output tableExample output:
Name ResourceGroup MasterVersion Upgrades ------- -------------------------------- --------------- -------------- default myResourceGroup-rg-chinanorth3 1.30.6 1.31.1, 1.31.2List the node pools in the AKS cluster using the
az aks nodepool listcommand.az aks nodepool list --resource-group $MY_RESOURCE_GROUP_NAME --cluster-name $MY_CLUSTER_NAME --output tableExample 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 UserOnce you decide your target Kubernetes version, you need to first upgrade the AKS control plane using the
az aks upgradecommand. 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 --yesUpgrade the
mongodbpoolnode pool to the newer version using theaz aks nodepool upgradecommand. 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 --yesThis 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
mongodbpoolnode pool using theaz aks nodepool listcommand.az aks nodepool list --resource-group $MY_RESOURCE_GROUP_NAME --cluster-name $MY_CLUSTER_NAME --output tableExample 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