Resolution
Check your worker nodes
To list the worker nodes that you registered to the Amazon EKS control plane, run the following command:
kubectl get nodes -o wide
In the output, you can view the name, Kubernetes version, operating system (OS), and IP address of the worker nodes.
To get additional information about a specific worker node, run the following command:
kubectl describe node/node_name
Note: Replace node_name with your worker node's Amazon Resource Name (ARN). For example, ip-AA-BB-CC-DD.us-east-1.compute.internal.
The output shows information about the worker node such as labels, taints, system information, and status.
Scale your worker nodes
Note: If your node groups appear in the Amazon EKS console, then use a managed node group to scale your worker nodes. Otherwise, use an unmanaged node group.
Use one of the following methods to scale your worker nodes.
Scale worker nodes with eksctl
To use eksctl to scale your managed or unmanaged worker nodes, run the following command:
eksctl scale nodegroup --cluster=clusterName --nodes=desiredCount --name=nodegroupName
Note: Replace clusterName with your cluster name, desiredCount with the number of nodes to scale to, and nodegroupName with the node group name.
Scale worker nodes without eksctl
To scale your managed worker nodes without eksctl, edit the node group configuration.
Scale worker nodes with CloudFormation
To use AWS CloudFormation to scale your unmanaged worker nodes, use a CloudFormation template to launch your worker nodes for Windows or Linux. Then, modify the NodeAutoScalingGroupDesiredCapacity, NodeAutoScalingGroupMinSize, or NodeAutoScalingGroupMaxSize parameters in your CloudFormation stack.
Drain your worker nodes
Important: The drain action isolates the worker node so that Kubernetes no longer schedules new Pods on the node. Kubernetes removes and stops Pods that run on the target node from draining nodes.
You can drain an entire node group or a single worker node.
Drain the entire node group
If you used eksctl to launch your worker nodes, then run the following command:
eksctl drain nodegroup --cluster=clusterName --name=nodegroupName
Note: Replace clusterName with your cluster name, and nodegroupName with your node group name.
To uncordon a drained node group, run the following command:
eksctl drain nodegroup --cluster=clusterName --name=nodegroupName --undo
Note: Replace clusterName with your cluster name, and nodegroupName with your node group name.
If you didn't use eksctl to launch your worker nodes, then run the following script to drain all the nodes of a specific Kubernetes version:
#!/bin/bash K8S_VERSION=1.18.8-eks-7c9bda
nodes=$(kubectl get nodes -o jsonpath="{.items[?(@.status.nodeInfo.kubeletVersion==\"v$K8S_VERSION\")].metadata.name}")
for node in ${nodes[@]}
do
echo "Draining $node"
kubectl drain $node --ignore-daemonsets --delete-local-data
done
Note: Replace 1.18.8-eks-7c9bda with your Kubernetes version.
To uncordon the drained nodes, run the following script:
#!/bin/bash K8S_VERSION=1.18.8-eks-7c9bda
nodes=$(kubectl get nodes -o jsonpath="{.items[?(@.status.nodeInfo.kubeletVersion==\"v$K8S_VERSION\")].metadata.name}")
for node in ${nodes[@]}
do
echo "Uncordon $node"
kubectl uncordon $node
done
Note: Replace 1.18.8-eks-7c9bda with your Kubernetes version.
To get your worker node version number, run the following command:
kubectl get nodesNAME
Note: Replace nodesNAME with your node name.
Example output:
$ kubectl get nodesNAME STATUS ROLES AGE VERSION
ip-ABC-ACB-DE-ABC.ec2.internal Ready <none> 6d4h v1.18.8-eks-7c9bda
ip-ABC-ABC-DE-ABC.ec2.internal Ready <none> 6d4h v1.18.8-eks-7c9bda
The version number appears in the VERSION column.
Drain a single worker node
If you didn't use eksctl to launch your worker nodes or to drain a specific node, then gracefully isolate your worker node. Run the following command:
kubectl drain node_name --ignore-daemonsets
Note: Replace node_name with your node name.
To undo the isolation, run the following command:
kubectl uncordon node_name
Note: Replace node_name with your node name.
You can also migrate your existing applications to a new worker node group.
Delete your worker nodes
Important: You can't undo a delete action.
If you use eksctl, then run the following command:
eksctl delete nodegroup --cluster=clusterName --name=nodegroupName
Note: Replace clusterName with your cluster name, and nodegroupName with your node group name.
If you have a managed node group, then see Delete a managed node group from your cluster.
If you have an unmanaged node group, and you used a CloudFormation template to launch your worker nodes, then delete the node group's stack.
If you have an unmanaged node group, but you didn't use a CloudFormation template, then delete the Amazon Elastic Compute Cloud (Amazon EC2) Auto Scaling group. If you didn't use an Amazon EC2 Auto Scaling group, then terminate the instance.