"How can I check, scale, delete, or drain my worker nodes in Amazon EKS?"
"I launched my Amazon Elastic Kubernetes Service (Amazon EKS) worker nodes using eksctl or the AWS Management Console. Now I want to check, scale, drain, or delete my worker nodes."
"I launched my Amazon Elastic Kubernetes Service (Amazon EKS) worker nodes using eksctl or the AWS Management Console. Now I want to check, scale, drain, or delete my worker nodes.Short descriptionComplete the steps in the appropriate section based on your needs:Check your worker nodesScale your worker nodesDrain your worker nodesDelete your worker nodesResolutionCheck your worker nodesTo list the worker nodes registered to the Amazon EKS control plane, run the following command:kubectl get nodes -o wideThe output returns the name, Kubernetes version, operating system, and IP address of the worker nodes.To get additional information on a single worker node, run the following command:kubectl describe node/node_nameNote: Replace node_name with your value. For example: ip-XX-XX-XX-XX.us-east-1.compute.internalThe output shows more information about the worker node, including labels, taints, system information, and status.Scale your worker nodesNote: If your node groups appear in the Amazon EKS console, then use a managed node group. Otherwise, use an unmanaged node group.(Option 1) To scale your managed or unmanaged worker nodes using eksctl, run the following command:eksctl scale nodegroup --cluster=clusterName --nodes=desiredCount --name=nodegroupNameNote: Replace clusterName, desiredCount, and nodegroupName with your values.-or-(Option 2) To scale your managed worker nodes without eksctl, complete the steps in the "To edit a node group configuration" section of Updating a managed node group.-or-(Option 3) To scale your unmanaged worker nodes using AWS CloudFormation, complete the following steps:1.    Use a CloudFormation template to launch your worker nodes for Windows or Linux.2.    Modify the NodeAutoScalingGroupDesiredCapacity, NodeAutoScalingGroupMinSize, or NodeAutoScalingGroupMaxSize parameters in your CloudFormation stack.Drain your worker nodesImportant: The drain action isolates the worker node and tells Kubernetes to stop scheduling any new pods on the node. Pods running on the target node are evicted from draining nodes, which means the pods will be stopped. Consider the effect this can have on your production environment.You can drain either an entire node group or a single worker node. Choose the appropriate option.(Option 1) Drain the entire node group:If you're using eksctl to launch your worker nodes, then run the following command:eksctl drain nodegroup --cluster=clusterName --name=nodegroupNameNote: Replace clusterName and nodegroupName with your values.To uncordon the node group, run the following command:eksctl drain nodegroup --cluster=clusterName --name=nodegroupName --undoNote: Replace clusterName and nodegroupName with your values.If you're not using eksctl to launch your worker nodes, then identify and drain all the nodes of a particular Kubernetes version. For example:#!/bin/bashK8S_VERSION=1.18.8-eks-7c9bdanodes=$(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-datadoneTo identify and uncordon all the nodes of a particular Kubernetes version, use the following code:#!/bin/bashK8S_VERSION=1.18.8-eks-7c9bdanodes=$(kubectl get nodes -o jsonpath="{.items[?(@.status.nodeInfo.kubeletVersion==\"v$K8S_VERSION\")].metadata.name}")for node in ${nodes[@]}do    echo "Uncordon $node"    kubectl uncordon $nodedoneNote: To get the version of your worker node, run the following command:$ kubectl get nodesNAME                                      STATUS   ROLES    AGE     VERSIONip-XXX-XXX-XX-XXX.ec2.internal            Ready    <none>   6d4h    v1.18.8-eks-7c9bdaip-XXX-XXX-XX-XXX.ec2.internal            Ready    <none>   6d4h    v1.18.8-eks-7c9bdaNote: The version number appears in the VERSION column.(Option 2) Drain a single worker node:If you're not using eksctl to launch your worker nodes or you want to drain only a specific node, then gracefully isolate your worker node:kubectl drain node_name --ignore-daemonsetsNote: Replace node_name with your value.To undo the isolation, run the following command:kubectl uncordon node_nameNote: Replace node_name with your value.To migrate your existing applications to a new worker node group, see Migrating to a new node group.Delete your worker nodesImportant: The delete action is unrecoverable. Consider the impact this can have on your production environment.If you're using eksctl, then run the following command:eksctl delete nodegroup --cluster=clusterName --name=nodegroupNameIf you have a managed node group, then complete the steps in Deleting a managed node group.If you have an unmanaged node group and you launched your worker nodes with a CloudFormation template, then delete the CloudFormation stack. You must delete the stack that you created for your node group for Windows or Linux.If you have an unmanaged node group and didn't use a CloudFormation template to launch your worker nodes, then delete the Auto Scaling group for your worker nodes. Or, terminate the instance directly if you didn't use an Auto Scaling group.Follow"