Upgrading the EKS Cluster Using Terraform
Continuation and Upgrade Process
Building upon the previous tutorial on creating an AWS EKS Cluster with a Managed Node Group using Custom Launch Templates, this tutorial focuses on upgrading the EKS cluster seamlessly using Terraform.
The upgrade process involves updating the cluster and add-on versions while excluding the worker node AMI update, typically handled by automated scripts in production environments.
Let's begin the upgrade process:
Step 1: Cordon the Nodes
Before initiating the upgrade, it is essential to cordon all nodes. This ensures that no new pods are scheduled on the nodes, allowing existing pods to continue running until they are rescheduled or terminated.
Execute the following commands to cordon the nodes:
kubectl cordon <node-name>
Replace <node-name>
with the name of each node in your cluster.
Step 2: Upgrade the Control Plane
In the terraform.tfvars
file, update the cluster_version
to 1.28
from 1.27
. Ensure to follow the version compatibility guidelines; direct upgrades to version 1.29
from 1.27
are not supported.
Step 3: Update the AMI ID
If a new AMI for the worker nodes has been created, modify the ami_id
in the terraform.tfvars
file accordingly.
Step 4: Upgrade the Add-ons
Ensure both installed add-ons, vpc-cni
and kube-proxy
, are updated in the terraform.tfvars
file. The vpc-cni
version v1.18.0-eksbuild.1
is compatible with EKS version 1.28
and does not require modification. Update kube-proxy
to version v1.28.6-eksbuild.2
.
Step 5: Apply the Changes
Execute terraform apply
to initiate the upgrade process. Allow Terraform to apply the changes and upgrade the EKS cluster. Monitor the process to ensure the upgrade completes and verify the updated configurations post-upgrade.
Step 6: Verify the changes
- Verify that the cluster has been upgraded properly from AWS UI.
By following these steps, you can successfully upgrade your EKS cluster to Kubernetes version 1.28 using Terraform. Be sure to thoroughly verify the upgrade to confirm its success and ensure all components function as expected.
Conclusion
Upgrading the Kubernetes version of your Amazon EKS cluster is essential to leverage the latest enhancements and security updates. This process not only enhances the performance and reliability of your applications but also ensures compatibility with new features and optimizations offered by Kubernetes. Regular upgrades are crucial to maintaining a secure and efficient Kubernetes environment, aligning your infrastructure with industry best practices and AWS service capabilities.
Subscribe to my newsletter
Read articles from Saurabh Adhau directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Saurabh Adhau
Saurabh Adhau
As a DevOps Engineer, I thrive in the cloud and command a vast arsenal of tools and technologies: โ๏ธ AWS and Azure Cloud: Where the sky is the limit, I ensure applications soar. ๐จ DevOps Toolbelt: Git, GitHub, GitLab โ I master them all for smooth development workflows. ๐งฑ Infrastructure as Code: Terraform and Ansible sculpt infrastructure like a masterpiece. ๐ณ Containerization: With Docker, I package applications for effortless deployment. ๐ Orchestration: Kubernetes conducts my application symphonies. ๐ Web Servers: Nginx and Apache, my trusted gatekeepers of the web.