by Nivesh Goyal, DevOps Engineer, Devtron
In this blog, we will discuss the steps necessary for upgrading the EKS cluster from version 1.16 to version 1.17.
What is EKS?
EKS stands for Elastic Kubernetes Service, which is one of the services provided by AWS. It helps run the Kubernetes on AWS without requiring the user to maintain their own Kubernetes control plane or the worker nodes.
Upgrading EKS Cluster Version:
The cluster managed or created by eksctl can be upgraded with the below steps:
- Upgrade EKS plane
- Create New Node Group
- Update Kube-proxy (Kubernetes add-ons or Components)
- Update aws-node (Kubernetes add-ons or Components)
- Update core-dns (Kubernetes add-ons or Components)
- Drain and Delete Old Nodegroups
1. Upgrade EKS Plane:
Commands to Upgrade the Control plane :
To upgrade the EKS cluster plane to another version, just run these simple commands:
$ eksctl upgrade cluster --name= --approve
Or
$ eksctl upgrade cluster --name= --approve
Or
You can do it via the Yaml file, which is given below:
$ cat cluster1.yaml__ apiVersion: eksctl.io/v1alpha5 kind: ClusterConfig metadata: name: cluster-1 region: eu-north-1 version: “1.17”$ eksctl upgrade cluster --config-file cluster1.yaml
NOTE:
The Control plane version can be upgraded only by one minor version (For example, 1.16 to 1.17 only), but you can upgrade your nodes up to two minor versions at a time.
When you upgrade the cluster, Amazon EKS requires 2–3 free IP addresses from the subnets you provided at the time of cluster creation. If subnets do not have enough available IP addresses, the upgrade can fail and result in “InsufficientFreeAddresses” error.
If the EKS cluster has Fargate pods, check Fargate pod’s kublete version. If kubelet version is less than 1.16, recycle Fargate pods so that their kubelet version will be 1.16. Otherwise, the cluster upgrade will fail.
If any of the subnets or security groups provided during cluster creation have been deleted, the cluster upgrade process can fail.
When you update your cluster, Amazon EKS does not upgrade any of your Kubernetes add-ons. After updating your cluster, you have to update your add-ons version as well.
2. Create New Node Group:
After running the above cluster upgrade commands, you can create or upgrade your node groups. You can create node groups in the following ways:
If you have a single node group, you can create a node group by CLI, run this command:
$ eksctl create nodegroup --cluster= --name=
If you have multiple node groups and have created them using a config file, you can also create node groups by config/yaml file. Remove old node groups and add new node groups to this config file and then run the command:
$ eksctl create nodegroup --config-file=
The above command will create new node groups
$ eksctl create nodegroup --config-file= --only-missing
The above command will delete older nodegroups
3. Update Kube-Proxy:
This command also supports the “–config-file” flag and the command run in plan mode, similar to dry-run. If you want to apply all the changes or the changes are as per your requirement, you have to re-run this command with the “–approve” flag. You can update Kube-proxy by the following command.
$ eksctl utils update-kube-proxy
4. Update aws-node:
This command also supports the “–config-file” flag and to apply all changes re-run with the “–approve” flag. You can update Kube-proxy by the following command.
$ eksctl utils update-aws-node
5. Update Core-DNS:
This command also supports the “–config-file” flag and to apply all the changes re-run with the “–approve” flag. You can update Kube-proxy by the following command.
$ eksctl utils update-coredns
NOTE:
Once the above components are updated, you have to check whether all components are in running state or not by running this command:
$ kubectl get pods -n kube-system
6. Drain and Delete Old Node Groups:
Important: The drain action isolates the worker node and tells Kubernetes to stop scheduling any new pods on the node. To drain the node groups, run the following command, and if you want to undo the draining, use “–undo” with the command:
$ eksctl drain nodegroup --cluster= --name=
To delete the old node groups, run the following commands:
$ eksctl drain nodegroup --cluster= --name=
If you are using a config file to create and delete the node groups, then change the node groups in a config file and run the following command with the “–approve” flag:
$ eksctl delete nodegroup --config-file= --only-missing --approve
That’s all about upgrading the Amazon EKS cluster using eksctl.