Sub topic 17
Observing and troubleshooting node autoscaling
This chapter assumes you know Pods, Deployments, resource requests, and the basics of the Cluster Autoscaler and Karpenter from earlier chapters. It shows where to look when nodes do not appear or do not go away.
Start with the Pending pod
Every scale-up begins with a pod the scheduler could not place. Check the pod first, then the autoscaler.
kubectl get pods -l app=inflate
kubectl describe pod -l app=inflate | grep -A5 Events
kubectl get events --sort-by=.lastTimestamp
kubectl get nodes -wA FailedScheduling event names the reason, such as Insufficient cpu or node(s) didn't match Pod's node affinity/selector. The autoscaler reacts only to pods that are unschedulable for resource reasons it can fix by adding a node.
flowchart TDWhere each autoscaler reports
| Signal | Cluster Autoscaler | Karpenter |
|---|---|---|
| Logs | Deployment in `kube-system` | Controller in its install namespace, often `kube-system` or `karpenter` |
| Pod events | `TriggeredScaleUp`, `NotTriggerScaleUp` | `Nominated`, `FailedScheduling` |
| Status | `cluster-autoscaler-status` ConfigMap | `NodeClaim` and `NodePool` status conditions |
| Metrics | `cluster_autoscaler_*` | `karpenter_*` |
Read the Cluster Autoscaler status with kubectl -n kube-system get configmap cluster-autoscaler-status -o yaml. It shows node group health and recent scale activity.
For Karpenter, list the objects it creates:
kubectl get nodepools
kubectl get nodeclaims
kubectl describe nodeclaim <name>
kubectl logs -n kube-system deploy/karpenter | tail -50A NodeClaim is Karpenter's request for one node. If it stays unready, its conditions and the controller log usually show the cloud error.
Common scale-up failures
- Request larger than any node. A pod asking for 64 CPUs never fits a pool that tops out at 16. Neither autoscaler can help.
- Constraint no group satisfies. A
nodeSelectoror toleration with no matching node group or NodePool requirement givesNotTriggerScaleUp. - Limit reached. The node group has hit its max size, or the NodePool
limits.cpuis used up. - Cloud errors. Instance quota, no spot capacity, a missing IAM permission, or subnets with no free IPs. These appear in the autoscaler logs or the NodeClaim conditions.
Common scale-down failures
Nodes stay when something blocks eviction. Look for these:
- A PodDisruptionBudget that allows zero disruptions.
- Pods with local storage, no controller, or the
cluster-autoscaler.kubernetes.io/safe-to-evict: "false"annotation (Cluster Autoscaler). - The
karpenter.sh/do-not-disrupt: "true"annotation or a NodePool disruption budget set to zero (Karpenter). - Utilization above the scale-down threshold, or the node is still inside the cool-down window.
Exercise
A pod is Pending with the event 0/5 nodes are available: 5 node(s) didn't match Pod's node affinity/selector. The Cluster Autoscaler logs show no scale-up. What is the likely cause and fix?
Show answer
No node group offers nodes that match the pod's selector or affinity, so adding a node from an existing group would not help. Fix the selector, or add or label a node group (or NodePool requirement) that satisfies it.