Expanding and Shrinking Kubernetes Clusters with Nutanix Kubernetes Engine (NKE)
In our previous article, we deployed a Kubernetes cluster using the Nutanix Kubernetes Engine (NKE). Today, we will explore how to expand or shrink the cluster as needed. This is crucial for day-two operations and ensures that the cluster can scale up or down based on changing requirements.
Scaling Up the Cluster
————————
To add more worker nodes to our existing cluster, we need to follow these steps:
1. Click on the “Node Pools” menu.
2. Select the “Worker” pool.
3. Click on the “Actions” button.
4. Select “Resize” from the dropdown menu.
5. Increase the total number of nodes in the pool to the desired number.
As we can see, NKE will create a new worker node and join it to the cluster. We can then scale an existing deployment to run on the new worker:
1. Click on the “Deployments” menu.
2. Select the deployment we want to scale.
3. Click on the “Actions” button.
4. Select “Scale” from the dropdown menu.
5. Enter the desired number of replicas for the deployment.
After scaling the deployment, we can see that four containers are running on the new worker:
Shrinking the Cluster
———————
To shrink our cluster, we need to follow these steps:
1. Click on the “Node Pools” menu.
2. Select the “Worker” pool.
3. Click on the “Actions” button.
4. Select “Resize” from the dropdown menu.
5. Decrease the total number of nodes in the pool to the desired number.
As we can see, NKE will delete worker nodes one by one, and pods will be redeployed on the remaining nodes. We need to ensure that the minimal number of worker nodes for a production cluster is three:
1. Click on the “Node Pools” menu.
2. Select the “Worker” pool.
3. Click on the “Actions” button.
4. Select “Delete” from the dropdown menu.
5. Confirm the deletion of the desired worker node.
After deleting a worker node, we may face an error if the cluster health is not normal:
1. Check the /home/nutanix/data/logs/karbon_core.out log file to troubleshoot the NKE issues.
2. Resize the worker pool again with a minimum of three nodes as required for a production deployment.
Creating a New Worker Pool
—————————-
To create a new worker pool, we need to follow these steps:
1. Click on the “Node Pools” menu.
2. Select “Add Node Pool” from the dropdown menu.
3. Specify the settings for the new pool, such as the number of nodes and their configuration.
4. Click “Add” to create the new pool.
5. The procedure should begin, and we can see that the new pool is deploying:
After creating a new worker pool, we can run containers on the new nodes:
1. Click on the “Deployments” menu.
2. Select the deployment we want to run on the new nodes.
3. Click on the “Actions” button.
4. Select “Scale” from the dropdown menu.
5. Enter the desired number of replicas for the deployment.
Conclusion
———-
In this article, we explored how to expand and shrink Kubernetes clusters with Nutanix Kubernetes Engine (NKE). We learned how to add more worker nodes to our existing cluster, delete worker nodes, and create a new worker pool. Remember that the minimal number of worker nodes for a production cluster is three. By following these steps, we can ensure that our Kubernetes cluster can scale up or down based on changing requirements.