<p>Sometimes we need to drain nodes in Kubernetes. When I manually set up a k8s cluster, I can drain the specific node then terminate that machine. While in EKS, nodes are under auto scaling group, which means I can't terminate a specific instance(node). If I manually terminate a instance, another instance(node) will be automatically added into eks cluster.</p>

<p>So is there any suggested method to drain a node in EKS?</p>

<p>These steps should work:</p>
<ol>
<li><code>kubectl get nodes</code></li>
<li><code>kubectl cordon &lt;node name&gt;</code></li>
<li><code>kubectl drain &lt;node name&gt; --ignore-daemonsets</code> or<br />
<code>kubectl drain &lt;node name&gt; --ignore-daemonsets --delete-emptydir-data</code></li>
<li><code>aws autoscaling terminate-instance-in-auto-scaling-group --instance-id &lt;instance-id&gt; --should-decrement-desired-capacity</code></li>
</ol>
<p>For AWS autoscaling group, if you have nodes span out to multiple zones, consider delete nodes in each zones instead of all nodes from a single zone.</p>
<p>After the execution of the above commands, check the autoscaling group's desired number.  It should decrease automatically.  If you are using Terraform or another automation framework, don't forget to update your autoscaling group config in your infrastructure script.</p>
