DEV Community

Cover image for Use of Node Pool snapshot in AKS
MakendranG
MakendranG

Posted on • Updated on

Use of Node Pool snapshot in AKS

Every new cluster, new pool, or upgrade cluster will always receive the latest image from AKS, which can make it hard to maintain your environments consistent and to have repeatable environments.

You can take a configuration snapshot of your pool and then create new pools or clusters based on that snapshot as long as the configuration is supported.

The snapshot is a resource that contains the configuration information from the source pool. You can use the snapshot resource and the values of the configuration to create a new pool or cluster.

Before you start

This article assumes that you have an existing AKS cluster.

Limitations

  • You cannot create a new N-Series pool based on a snapshot captured from a D-Series pool because the images in those cases are not the same as the virtual machine family.
  • Snapshots can be used in the same region as the source pool.

Take a snapshot of the node pool.

To take a snapshot from a node pool, you need the resource ID, which you can get from the command below.

NODEPOOL_ID=$(az aks nodepool show --name nodepool1 --cluster-name kcdCluster --resource-group kcdrg --query id -o tsv)
Enter fullscreen mode Exit fullscreen mode

You can use the az aks snapshot cli command to take a snapshot from the previous pool.

az aks snapshot create --name kcdSnapshot --resource-group kcdrg --nodepool-id $NODEPOOL_ID --location centralus
Enter fullscreen mode Exit fullscreen mode

To get the resource ID from the snapshot that was previously created, you need to use the command below.

SNAPSHOT_ID=$(az aks snapshot show --name kcdSnapshot --resource-group kcdrg --query id -o tsv)
Enter fullscreen mode Exit fullscreen mode

The command below can be used to add a new pool based on this snapshot.

az aks nodepool add --name np2 --cluster-name kcdCluster --resource-group kcdrg --snapshot-id $SNAPSHOT_ID
Enter fullscreen mode Exit fullscreen mode

If the snapshots version and image version are more recent than the versions in the current pool, you can upgrade it to a snapshot configuration.

To get the resource ID from the snapshot that was previously created, you need to use the command below.

SNAPSHOT_ID=$(az aks snapshot show --name kcdSnapshot --resource-group kcdrg --query id -o tsv)
Enter fullscreen mode Exit fullscreen mode

We can use this command to upgrade this pool.

az aks nodepool upgrade --name nodepool1 --cluster-name kcdCluster --resource-group kcdrg --snapshot-id $SNAPSHOT_ID
Enter fullscreen mode Exit fullscreen mode

A snapshot can be used to create a cluster. The original system pool will be created when you create a cluster from a snapshot.

To get the resource ID from the snapshot that was previously created, you need to use the command below.

SNAPSHOT_ID=$(az aks snapshot show --name kcdSnapshot --resource-group kcdrg --query id -o tsv)
Enter fullscreen mode Exit fullscreen mode

This command can be used to create this cluster of the snapshot configuration.

az aks create --name kcdCluster2 --resource-group kcdrg --snapshot-id $SNAPSHOT_ID
Enter fullscreen mode Exit fullscreen mode

Thanks for reading my article till end. I hope you learned something special today. If you enjoyed this article then please share to your friends and if you have suggestions or thoughts to share with me then please write in the comment box.

Above blog is submitted as part of 'Devtron Blogathon 2022' - https://devtron.ai/
Check out Devtron's GitHub repo - https://github.com/devtron-labs/devtron/ and give a ⭐ to show your love & support.
Follow Devtron on LinkedIn - https://www.linkedin.com/company/devtron-labs/ and Twitter - https://twitter.com/DevtronL/, to keep yourself updated on this Open Source project.

Top comments (0)