The mystery of the 12 nodes that refused to disappear
One of the interesting problems in Kubernetes infrastructure is not always scaling up. Sometimes the more expensive problem is getting the cluster to scale down.
Imagine a cluster where application deployments have been deleted, workloads have reduced significantly, and only a handful of pods remain.
You expect Karpenter to identify unused capacity and terminate unnecessary EC2 instances.
But nothing happens.
The Kubernetes cluster continues running with approximately 12 worker nodes, even though the actual workload no longer justifies that capacity.
You check the NodePool configuration. Consolidation is enabled. The policy is set to WhenEmptyOrUnderutilized. The consolidation delay is configured to just 30 seconds.
Everything looks correct at first glance.
So why are the nodes still running?
This investigation explores the mechanisms behind Karpenter consolidation and provides a systematic troubleshooting approach to identify why apparently idle nodes are not being removed.
Important: This is an investigation-led technical case study based on the observed cluster symptoms and configuration context. The exact production root cause must be established from the corresponding Kubernetes events, NodeClaims and Karpenter controller logs.
1. Incident Overview
What we observed
The investigation involved two Kubernetes environments:
| Environment | Observation |
|---|---|
| TEST | Cluster remained overprovisioned despite a significant reduction in workloads |
| E2E | Workload count was extremely low, but approximately 12 nodes remained active |
The relevant NodePool configuration contained:
disruption:
consolidationPolicy: WhenEmptyOrUnderutilized
consolidateAfter: 30sThe environment was using Karpenter v1.12.1.
A scheduled configuration was also present:
0 7,19 * * *The schedule needs to be interpreted in the context of the complete NodePool disruption-budget configuration. A cron schedule in a disruption budget controls when that budget applies; it does not independently schedule a consolidation job.
Initial questions
We needed to establish:
- Were the nodes actually managed by Karpenter?
- Were there any remaining workload pods?
- Were DaemonSets or system workloads occupying the nodes?
- Were PodDisruptionBudgets preventing eviction?
- Were scheduling constraints preventing pods from moving?
- Were NodePool disruption budgets restricting consolidation?
- Was Karpenter identifying candidates but failing to execute termination?
The distinction matters: a node that is not considered for consolidation requires a different investigation from a node that has already entered the disruption process but cannot complete draining.
2. Understanding How Karpenter Consolidation Works
Karpenter is not simply a CPU-based autoscaler.
It continuously evaluates the relationship between workloads, available capacity, scheduling constraints and infrastructure cost.
When it identifies an opportunity to reduce capacity, it attempts to determine whether existing workloads can be accommodated on fewer or cheaper nodes.
There are two important consolidation outcomes:
- Deletion: A node can be removed because its workloads can fit on existing available capacity.
- Replacement: A node can be replaced with a more cost-effective instance configuration when the scheduling and pricing simulation permits it.
This means that an apparently idle node is not necessarily eligible for termination.
Consolidation lifecycle
The important point is that consolidation is a multi-stage process.
A failure or restriction at any stage can prevent the node from disappearing.
3. First Investigation: Verify Karpenter Ownership
Before investigating consolidation policies, establish whether Karpenter actually owns the nodes.
Karpenter-managed nodes normally expose ownership-related labels and annotations.
Start with:
kubectl get nodes \
-L karpenter.sh/nodepool \
-L karpenter.sh/capacity-typeInspect the NodeClaims:
kubectl get nodeclaims -o wideNodeClaims represent Karpenter's cloud capacity requests and provide another important view of the relationship between Kubernetes Nodes and cloud instances.
Inspect an individual NodeClaim:
kubectl describe nodeclaim <nodeclaim-name>Look for:
- NodePool ownership.
- Node initialization conditions.
- Provider ID.
- Resource capacity.
- Disruption-related conditions.
- Termination state.
Also inspect the NodePool:
kubectl get nodepool
kubectl describe nodepool <nodepool-name>What are we trying to establish?
If the node is not managed by the expected NodePool, changing the consolidation configuration of that NodePool will not solve the problem.
Similarly, if a node has not completed initialization, Karpenter may not consider it eligible for automatic deprovisioning.
4. Second Investigation: Is the Node Actually Empty?
A common troubleshooting mistake is equating an empty application namespace with an empty Kubernetes node.
A node can have no application deployments and still run:
- Fluent Bit.
- Prometheus node exporters.
- CNI components.
- CSI components.
- Security agents.
- Other infrastructure DaemonSets.
List pods on a specific node:
NODE=<node-name>
kubectl get pods -A \
--field-selector spec.nodeName="$NODE" \
-o wideInspect node details:
kubectl describe node "$NODE"Pay particular attention to:
- Non-terminated pods.
- Allocated CPU and memory requests.
- Node taints.
- Node conditions.
- Scheduling restrictions.
Why DaemonSets matter
DaemonSet pods are generally handled specially during Karpenter's emptiness and termination evaluations. Their presence alone does not necessarily mean that a node cannot be consolidated.
However, they should not be ignored.
For example, a security agent may run on every worker node, while an application pod may be the actual workload preventing consolidation.
The investigation must distinguish between infrastructure-managed pods and ordinary workloads.
5. Third Investigation: PodDisruptionBudgets
This is one of the most important areas to investigate.
A PodDisruptionBudget (PDB) protects application availability during voluntary disruptions.
Suppose an application has five replicas:
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: checkout-pdb
spec:
minAvailable: 5
selector:
matchLabels:
app: checkoutThe PDB requires all five replicas to remain available.
If a node contains one of these replicas, Karpenter may be unable to evict it without violating the budget.
The node therefore cannot complete its voluntary disruption.
Check all PDBs:
kubectl get pdb -AInspect the relevant PDB:
kubectl describe pdb checkout-pdb -n productionCheck:
- Allowed disruptions.
- Current healthy replicas.
- Desired healthy replicas.
- Matching pods.
A particularly important condition is:
ALLOWED DISRUPTIONS: 0This is a strong indication that eviction may be blocked.
However, the PDB must actually select the pod on the candidate node before attributing the blockage to it.
A second blocker: do-not-disrupt
Karpenter also supports the pod annotation:
metadata:
annotations:
karpenter.sh/do-not-disrupt: "true"This annotation protects a pod from Karpenter's voluntary disruption process.
A node containing a pod with an active do-not-disrupt annotation may therefore remain unavailable for consolidation.
Find annotated pods:
kubectl get pods -A -o json | jq -r '
.items[]
| select(.metadata.annotations["karpenter.sh/do-not-disrupt"] != null)
| [
.metadata.namespace,
.metadata.name,
.spec.nodeName,
.metadata.annotations["karpenter.sh/do-not-disrupt"]
]
| @tsv'Do not remove these annotations blindly. First establish why the application requires disruption protection.
6. Fourth Investigation: Scheduling Constraints
A node may have very low resource utilization and still be impossible to consolidate.
Why?
Because Karpenter needs to establish that the existing pods can run somewhere else.
Consider the following example:
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchLabels:
app: payment
topologyKey: kubernetes.io/hostnameThis configuration requires matching payment pods to run on different nodes.
If the remaining nodes cannot satisfy this requirement, Karpenter cannot safely consolidate the candidate node.
Other important scheduling restrictions include:
- Node affinity.
- Pod affinity.
- Pod anti-affinity.
- Topology spread constraints.
- Taints and tolerations.
- Persistent volume topology.
- Available CPU and memory requests.
- Instance type and architecture requirements.
Example: Why low CPU utilization is misleading
Consider this hypothetical cluster:
| Node | CPU requested | Memory requested | Workloads |
|---|---|---|---|
| Node A | 8% | 12% | Payment API |
| Node B | 7% | 10% | Payment API |
| Node C | 5% | 9% | Payment API |
All three nodes appear underutilized.
But if required anti-affinity forces each payment API replica onto a different hostname, Karpenter cannot simply place all three replicas on one node.
The scheduling simulation determines whether consolidation is possible.
CPU utilization alone cannot answer that question.
7. Fifth Investigation: NodePool Disruption Budgets
Even when a node is a valid consolidation candidate, NodePool disruption budgets can restrict how many nodes Karpenter may disrupt.
Example:
spec:
disruption:
budgets:
- nodes: "10%"A budget of 10% limits simultaneous voluntary disruptions relative to the NodePool's node population, subject to Karpenter's budget calculation.
Multiple budgets can apply simultaneously. The most restrictive applicable budget wins.
Scheduled disruption budgets
A configuration can also contain a schedule:
spec:
disruption:
budgets:
- nodes: "0"
schedule: "0 7,19 * * *"
duration: 30m
reasons:
- UnderutilizedThis example blocks underutilized-node disruptions during the configured scheduled windows.
It is important to understand what this means:
- The schedule controls when the budget is active.
- The duration defines the active period.
- The nodes field defines the disruption allowance.
- The reasons field determines which disruption reasons the budget applies to.
A schedule is not a command telling Karpenter to scale down at 07:00 and 19:00.
For the actual environment, inspect the complete NodePool YAML before deciding whether its schedule is blocking consolidation.
kubectl get nodepool <nodepool-name> -o yamlInspect the entire spec.disruption section, not just the cron expression.
8. Sixth Investigation: The 30-Second Consolidation Delay
The configuration:
consolidateAfter: 30sis easy to misunderstand.
It does not mean that Karpenter guarantees node termination 30 seconds after a workload is deleted.
It defines how long Karpenter waits after a pod is added to or removed from a node before considering that node for consolidation.
The timer can reset when pod placement changes.
After the delay, Karpenter still needs to:
- Identify a consolidation candidate.
- Simulate pod rescheduling.
- Evaluate disruption budgets.
- Respect eviction requirements.
- Execute the termination process.
Therefore:
30 seconds is an eligibility delay, not an end-to-end termination SLA.
Increasing or decreasing this value without understanding the actual blocker may have no effect.
9. Seventh Investigation: Karpenter Controller Logs and Events
This is where the investigation should move from assumptions to evidence.
Inspect Karpenter controller pods:
kubectl get pods -n karpenterRead controller logs:
kubectl logs -n karpenter \
deployment/karpenter \
--since=1hFilter relevant messages:
kubectl logs -n karpenter \
deployment/karpenter \
--since=1h \
| grep -Ei 'consolidat|disrupt|blocked|pdb|nodeclaim|terminate'Inspect cluster events:
kubectl get events -A \
--sort-by=.lastTimestampCorrelate the following:
- Candidate identification.
- Consolidation decision.
- Scheduling simulation outcome.
- Disruption budget evaluation.
- Pod eviction attempts.
- NodeClaim termination.
- Cloud provider termination.
A message indicating that a node is not eligible for consolidation is very different from a message indicating that termination has started but draining is blocked.
The timestamps matter too. Correlate events with pod changes and controller logs rather than relying on a single snapshot.
10. Putting the Investigation Together
The following decision tree provides a repeatable approach.
The investigation should stop treating the node as simply idle and start identifying exactly which lifecycle stage prevents its removal.
11. Recommended Remediation Strategy
Do not immediately increase disruption aggressiveness or remove protection mechanisms.
Remediation should follow the evidence.
| Finding | Recommended action |
|---|---|
| Node not initialized | Resolve readiness, startup taints or missing expected resources |
| PDB blocks eviction | Review replica availability and PDB configuration with application owners |
| do-not-disrupt annotation | Validate whether protection is still required |
| Affinity prevents consolidation | Review workload placement requirements |
| Budget restricts disruption | Review NodePool disruption-budget policy |
| Pod churn resets timer | Investigate recurring scheduling and deployment activity |
| No candidate identified | Review controller logs, policy and scheduling simulation |
| NodeClaim termination incomplete | Investigate finalizers, drain state and cloud-provider lifecycle |
Suggested operational hardening
- Establish monitoring for the number of Karpenter-managed nodes versus actual workload demand.
- Alert on prolonged node overprovisioning.
- Monitor NodePool disruption budgets.
- Review PDB configurations regularly.
- Audit long-lived do-not-disrupt annotations.
- Test consolidation behaviour in lower environments.
- Correlate NodeClaim lifecycle events with EC2 instance state.
- Keep controller logs available for incident investigation.
12. Operational Verification
After remediation, verify that the expected capacity reduction actually occurred.
kubectl get nodes -o wide
kubectl get nodeclaims -o wide
kubectl get nodepoolVerify workloads:
kubectl get pods -A -o wideVerify that the cloud instances corresponding to terminated NodeClaims are no longer running.
Also monitor:
- Pending pods.
- Scheduling failures.
- Node provisioning frequency.
- Application availability.
- CPU and memory requests.
- Consolidation-related controller events.
A successful scale-down is not just a lower node count. It must preserve workload availability and leave sufficient capacity for expected demand.
13. Final Takeaways
Karpenter consolidation is a scheduling and disruption-management process, not a simple utilization threshold.
When a Kubernetes cluster retains unnecessary nodes, investigate the complete lifecycle:
- Node ownership and initialization.
- Actual workload placement.
- Consolidation eligibility.
- Scheduling feasibility.
- PDB and annotation restrictions.
- NodePool disruption budgets.
- Controller decisions and termination.
The most important lesson is this:
Never assume that Karpenter is broken just because an apparently idle node remains running. Find the exact stage where the consolidation lifecycle stops.
That is the difference between changing configuration until something works and conducting a proper SRE root-cause investigation.
---
References and Further Reading
- Karpenter — Disruption and Consolidation
- Karpenter — Troubleshooting
- Karpenter — NodePools
- Kubernetes — Pod Disruptions
- Kubernetes — Assigning Pods to Nodes
Editorial note: Configuration examples are illustrative. Validate API fields, defaults and behaviour against the exact Karpenter version deployed in your cluster before applying them.
