[{"content":"Sometimes you just want one specific node gone.\n⚠️ Anti-Pattern Alert!\nYeah, yeah — “cattle, not pets”. In theory you shouldn’t care. In reality, especially in enterprise setups, sometimes you do.\nHere’s how to do it properly in a Cluster API (CAPI) cluster without it coming back.\nThe catch CAPI is declarative.\nIf your cluster says:\n“I want N nodes”\n…it will keep N nodes.\nSo if you just do:\n1 kubectl delete node \u0026lt;node\u0026gt; It’ll come back.\nThe rule (don’t skip this) 1 2 Annotate first. Then reduce capacity. Are you using autoscaler? Quick check:\n1 kubectl get machinedeployments -A Pick your MachineDeployment name, then:\n1 kubectl get machinedeployment \u0026lt;md-name\u0026gt; -o yaml | grep autoscaler If you see:\n1 2 cluster.x-k8s.io/cluster-api-autoscaler-node-group-min-size cluster.x-k8s.io/cluster-api-autoscaler-node-group-max-size 👉 You’re using Cluster Autoscaler.\nOr:\n1 kubectl get pods -A | grep -i autoscaler If you see a cluster-autoscaler pod, same thing.\n💡 On platforms like Nutanix Kubernetes Platform, autoscaler is typically enabled.\nThe flow flowchart TD A[Find node] --\u0026gt; B[Find Machine + MachineDeployment] B --\u0026gt; C[Annotate Machine] C --\u0026gt; D{Autoscaler?} D --\u0026gt;|Yes| E[Update min/max] D --\u0026gt;|No| F[Scale replicas] Step 1 — Find your node List nodes:\n1 kubectl get nodes Pick the node you want to remove.\nStep 2 — Find the Machine and MachineDeployment Get all Machines:\n1 kubectl get machines -A Find the Machine that matches your node using:\n1 machine.status.nodeRef.name To get more details (including owner MachineDeployment):\n1 kubectl get machine \u0026lt;machine-name\u0026gt; -n \u0026lt;namespace\u0026gt; -o yaml Look for:\n1 ownerReferences → kind: MachineSet Then:\n1 kubectl get machineset \u0026lt;machineset-name\u0026gt; -n \u0026lt;namespace\u0026gt; -o yaml From there you’ll find the MachineDeployment name.\nStep 3 — Annotate the Machine 1 2 kubectl annotate machine \u0026lt;machine-name\u0026gt; -n \u0026lt;namespace\u0026gt; \\ cluster.x-k8s.io/delete-machine=\u0026#34;true\u0026#34; This tells CAPI:\n“When you scale down, delete this one.”\nStep 4 — Reduce capacity No autoscaler Scale the MachineDeployment:\n1 kubectl scale machinedeployment \u0026lt;md-name\u0026gt; -n \u0026lt;namespace\u0026gt; --replicas=\u0026lt;new-count\u0026gt; With autoscaler Update min/max instead:\n1 2 3 4 kubectl annotate machinedeployment \u0026lt;md-name\u0026gt; -n \u0026lt;namespace\u0026gt; \\ cluster.x-k8s.io/cluster-api-autoscaler-node-group-min-size=\u0026#34;\u0026lt;new-min\u0026gt;\u0026#34; \\ cluster.x-k8s.io/cluster-api-autoscaler-node-group-max-size=\u0026#34;\u0026lt;new-max\u0026gt;\u0026#34; \\ --overwrite If you’re testing this on Nutanix Kubernetes Platform, this is the path you’ll use.\nVerify 1 2 kubectl get machines -A kubectl get nodes TL;DR 1 2 3 4 5 6 7 1. kubectl get nodes 2. kubectl get machines -A 3. Find Machine + namespace 4. Annotate Machine 5. Then: - No autoscaler → scale MachineDeployment - Autoscaler → update min/max That’s it—no guessing, no missing steps.\n","permalink":"https://f1605f37.joseluisgomez-com.pages.dev/posts/2026-05-05-removing-a-specific-worker-node-in-a-capi-cluster/","summary":"Learn how to safely remove a specific worker node in a Cluster API (CAPI) Kubernetes cluster without it being recreated.","title":"Removing a Specific Worker Node in a CAPI Cluster"}]