Requests and limits look like Kubernetes 101 until you realize they show up everywhere: quotas count requests, OpenCost bills requests, LimitRanges inject them, Kyverno policies require them, HPAs divide by them, and our resources break drill corrupts them. Lock down these mechanics and four other sections immediately click into place.
make upOrientation
Just two numbers per container control scheduling, cost, eviction order, CPU throttling, and whether your app survives a noisy neighbor. Let's trace exactly what each number does at every layer.
A request is a reservation the scheduler uses for placement math; a limit is a hard ceiling the kernel enforces at runtime. Nothing reconciles the two after scheduling, which is how a node can burn 30% CPU while sitting 100% requested. Section 1.5 puts a dollar figure on that exact gap.
How requests and limits actually work
What the scheduler does with requests
The scheduler adds up the requests of every non-terminated pod on a node and checks the sum against the node's allocatable resources (not total capacity; allocatable is capacity minus kube-reserved, system-reserved, and eviction thresholds). Live CPU and memory usage never enter the equation. If a node is sitting at 5% real CPU with 100% of its millicores requested, the scheduler treats it as completely full.
node capacity ████████████████████████████████████████ 4000m
allocatable ██████████████████████████████████░░░░░░ 3800m (minus kubelet/system/eviction)
sum of requests ████████████████████████████████░░░░░░░░ 3600m ← what the scheduler sees
actual usage ██████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 1100m ← what you actually use; the rest is paid for anyway
└────────────────────┘
the right-sizing gap: 2500m reserved and never used
Try it live: push requests up until the node stops accepting pods, then drop live usage and watch how much idle capacity you're still paying for:
What the kernel does with limits
| Resource | request becomes | limit becomes | over the limit |
|---|---|---|---|
| cpu | cpu.weight (relative share) | cpu.max (quota per 100ms period) | throttled silently: no event, no restart |
| memory | eviction ranking only | memory.max | OOMKilled instantly by the kernel |
| ephemeral-storage | scheduling claim | kubelet-enforced | pod evicted |
| hugepages / devices | requests must equal limits; zero overcommit allowed | ||
CPU is compressible: blow past your limit and the CFS scheduler simply pauses your container until the next 100ms window. Latency-sensitive services with tight CPU limits suffer mysterious periodic stalls that masquerade as network blips. Check container_cpu_cfs_throttled_periods_total to spot it fast. Memory is incompressible: you can't "slow down" RAM, so crossing the ceiling brings down the OOM killer immediately.
On a one-shot pod (--restart=Never), an OOMKill appears in .status.containerStatuses[0].state.terminated.reason. On a crash-looping Deployment, the container has already bounced, so the proof lives in lastState.terminated.reason while state only shows waiting: CrashLoopBackOff. Looking at state alone and declaring "not an OOM" is an easy trap to avoid.
QoS classes: derive them, don't memorize them
| Class | Condition | Eviction order | oom_score_adj |
|---|---|---|---|
| Guaranteed | every container sets requests == limits for both CPU and memory | last | -997 |
| Burstable | at least one request or limit set, without qualifying for Guaranteed | middle: pods exceeding requests first | 2–999, scaled |
| BestEffort | no requests or limits set at all | first | 1000 |
Don't rely on rote recall: tweak the four numbers below and watch the QoS class, eviction rank, and runtime behavior update live:
When a node hits memory pressure, kubelet picks eviction victims in a clear order: pods exceeding their requests go first, ranked by Pod Priority (lowest first) and then by how far over their request they are. QoS class falls straight out of that rule: a BestEffort pod requested zero, so it's always over. Notice the practical takeaway: a high-priority Burstable pod outlives a low-priority BestEffort one, which is why PriorityClass shields platform agents from eviction as well as preemption. The kernel mirrors this ranking through oom_score_adj so node-level OOMs pick the same victim. And remember: CPU pressure never evicts pods, it only throttles them.
Placement levers, in the order you reach for them
| Lever | Direction | Hard or soft | Reach for it when |
|---|---|---|---|
| nodeSelector | pod → node labels | hard only | quick, blunt pinning |
| nodeAffinity | pod → node labels | required… / preferred… with weights | flexible pinning using operators (In, NotIn, Exists, Gt, Lt) |
| podAffinity / podAntiAffinity | pod → other pods within a topologyKey | both | co-locating with a cache or spreading replicas apart |
| taints + tolerations | node repels pods | NoSchedule, PreferNoSchedule, NoExecute | dedicated pools, control planes, GPU nodes |
| topologySpreadConstraints | even spread across a label domain | DoNotSchedule / ScheduleAnyway | zone or node balance with bounded skew (the modern default) |
| priorityClass | decides who wins on a full node | preemption | protecting platform components over tenant workloads |
Three subtleties show up constantly in tasks. First, taints repel pods, while tolerations only allow placement; they never attract pods on their own. To truly dedicate a node pool, pair a taint with a matching nodeAffinity. Second, NoExecute evicts already-running pods that lack the toleration (with optional tolerationSeconds grace delay). Third, pod anti-affinity gets expensive on large clusters, which is why topologySpreadConstraints is the preferred modern tool: cleaner intent, bounded cost, and explicit maxSkew.
Our kind config stamps its workers into two zones via topology.kubernetes.io/zone so you can actually test spread constraints. Run kubectl get nodes -L topology.kubernetes.io/zone before writing your manifest, because targeting a label key no node carries silently fails open under ScheduleAnyway and locks everything Pending under DoNotSchedule.
One availability neighbor worth keeping top of mind: a PodDisruptionBudget limits voluntary disruptions (node drains, cluster upgrades) using minAvailable or maxUnavailable. It won't stop crashes or hardware failures. Watch out for minAvailable: 100%: it's the fastest way to hang a cluster upgrade forever, and spotting that stalled-drain symptom is an easy exam win.
Autoscaling: different scalers for different jobs
| Scaler | Changes | Input | Gotcha |
|---|---|---|---|
| HPA | replica count | live metrics (Resource, Pods, Object, External) | requires metrics-server; percentage targets divide by requests |
| VPA | container requests | historical usage | fights HPA if both watch the same metric; updateMode: Off keeps it safely advisory |
| Cluster Autoscaler / Karpenter | node count or size | unschedulable pods | triggers on Pending pods, so it's downstream of requests too |
| KEDA | replicas, all the way to 0 | queue depth, topic lag, cron, external triggers | generates an HPA under the hood for External metrics, and handles scale-to-zero |
The HPA formula behind every scaling surprise
desiredReplicas = ceil( currentReplicas × ( currentMetricValue / desiredMetricValue ) )Keep two details in mind whenever an HPA seems stubborn: it ignores changes inside its tolerance band (10% by default), and it treats unready pods or pods with missing metrics specially. Also notice the denominator: with --cpu-percent=20 on containers requesting 25m CPU, the threshold is just 5m of actual CPU per pod. That's why tiny demo requests scale up under lightweight traffic: percentage targets are always relative to container requests, never node capacity.
By default, scale-up reacts fast while scale-down waits through a 300-second stabilization window to prevent flapping. You can tune both directions per HPA under spec.behavior using pod/percent policies and selectPolicy. Simply knowing that scale-down lag is deliberate saves you from chasing phantom bugs.
VPA update modes
Off: calculates recommendations without touching pods. The exam workhorse: gives you pure right-sizing data with zero disruption.Initial: injects recommendations only when new pods are created.Auto/Recreate: evicts and recreates pods to resize them (disruptive by design unless using in-place resize).
Modern Kubernetes clusters support resizing CPU and memory in place, softening that disruption trade-off. Don't probe for support with kubectl explain pod.spec.containers.resizePolicy, because that field has been in the schema since 1.27 regardless of whether the feature is enabled. Instead, check whether the pods/resize subresource exists via kubectl get --raw /api/v1 | grep -o 'pods/resize' (or test a patch directly).
Keep three commands in muscle memory: kubectl top pod --containers for live usage, kubectl describe node for the requests-vs-allocatable summary at the bottom (the best capacity snapshot in kubectl), and kubectl get vpa -o jsonpath='{.items[*].status.recommendation…}' for recommended targets.
Node scaling and disruption mechanics
Both Cluster Autoscaler and Karpenter react to the exact same trigger (Pending pods that can't fit on existing nodes), and both evaluate consolidation based on pod requests, never live usage. That's why right-sizing requests (1.5) has to come before expecting node-level savings.
Cluster Autoscaler vs Karpenter
| Aspect | Cluster Autoscaler | Karpenter |
|---|---|---|
| Unit it manages | pre-defined cloud node groups; selects a group via an expander (least-waste default, priority, most-pods, random) | NodePool constraints (families, zones, arch, karpenter.sh/capacity-type spot/on-demand) and per-node NodeClaims; provisions the cheapest fitting instance directly |
| Scale-down | node idle for --scale-down-unneeded-time (10m default) below --scale-down-utilization-threshold (0.5) | spec.disruption.consolidationPolicy (WhenEmpty, WhenEmptyOrUnderutilized) + consolidateAfter (or Never); can swap nodes for cheaper instances |
| Lifecycle | autoscaling only | also handles drift (replacing nodes when NodePool/AMI updates) and expiry (expireAfter, default 720h) |
| Rate limiting | CLI flags | spec.disruption.budgets (default nodes: 10%, optional cron schedules/reasons); spec.limits caps total pool CPU/memory |
| Pod opt-out | cluster-autoscaler.kubernetes.io/safe-to-evict: "false" | karpenter.sh/do-not-disrupt: "true" (or a duration) |
| What blocks removal | restrictive PDBs, bare pods with no controller, local-storage pods (CA), kube-system pods lacking a PDB (CA); both engines honor PDBs and back off when eviction is denied | |
Whenever a Karpenter node refuses to consolidate, check its events for Unconsolidatable, which spells out the exact blocker (like a PDB or missing cheaper replacement).
PodDisruptionBudget details
- Specify either
minAvailableormaxUnavailable(integer or percentage). Percentages read.spec.replicasfrom the owning controller, so bare unmanaged pods can't use percentage budgets. - PDBs only guard the Eviction API (node drains, autoscaler consolidation, descheduler). Hardware failures, OOMKills, and rolling updates bypass it (though they still eat into available headroom).
unhealthyPodEvictionPolicy(GA since 1.31):IfHealthyBudget(default) blocks evicting even broken pods until the budget is satisfied, which is how a crash-looping app stalls a drain;AlwaysAllowlets unhealthy pods get evicted cleanly and is Kubernetes' recommended setting for flaky workloads.- Scheduler preemption treats PDBs as best-effort: if no PDB-safe victim exists, it preempts anyway.
PriorityClass fields
- Cluster-scoped; user values go up to
1000000000, whilesystem-cluster-critical(2000000000) andsystem-node-critical(2000001000) are reserved for control plane and node agents. - At most one class can set
globalDefault: truefor pods that omitpriorityClassName(otherwise priority defaults to 0); changing it doesn't alter already-running pods. preemptionPolicy: Neverlets a workload jump ahead in the scheduling queue without kicking off lower-priority pods, making it ideal for batch jobs. The defaultPreemptLowerPriorityevicts victims.- A preempting pod records
status.nominatedNodeNamewhile victims shut down gracefully over theirterminationGracePeriodSeconds. - Use a ResourceQuota with
scopeSelector(scopeName: PriorityClass, operator: In, values: [high]) to stop tenants from abusing privileged priority lanes (section 1.4).
Where allocatable comes from
allocatable = capacity - kubeReserved - systemReserved - evictionHard. Kubelet subtracts kubeReserved (kubelet, runtime), systemReserved (sshd, kernel, journald), and evictionHard thresholds (defaults: memory.available: 100Mi, nodefs.available: 10%, nodefs.inodesFree: 5%, imagefs.available: 15%). By default enforceNodeAllocatable: [pods] only enforces pod cgroups; enforcing kube-reserved or system-reserved as well can hurt nodes if your estimates run tight. Always check Capacity vs. Allocatable in kubectl describe node before guessing why a pod won't schedule.
Node sizing rules of thumb
- Nodes default to 110 pods max (
maxPods). Because DaemonSets run on every node, lots of tiny nodes multiply DaemonSet overhead, whereas a few giant nodes widen single-node blast radius and make bin-packing chunky. Two to three zones with at least one spare node's headroom per zone is a solid sweet spot. - Bursty, request-heavy apps pack much more smoothly onto larger nodes; Guaranteed pods (requests == limits) pack tightest since nothing can share their slack.
- Isolate spot or preemptible capacity in a tainted NodePool reserved for stateless, PDB-backed workloads, never single-writer databases.
"A node has been cordoned for an hour and the drain still won't finish" is a textbook PDB puzzle. Run kubectl get pdb -A, find the budget showing ALLOWED DISRUPTIONS: 0, and choose the right fix: scale the Deployment up, loosen minAvailable, or switch to unhealthyPodEvictionPolicy: AlwaysAllow if the blocking pods are already unhealthy. Only delete the PDB outright if the prompt explicitly asks for it.
In-place resize and recent Kubernetes upgrades
In-place pod resize
InPlacePodVerticalScaling reached GA in Kubernetes 1.35 (alpha 1.27, beta and default-on in 1.33), so on our 1.37 lab cluster the pods/resize subresource is ready to go. Here's how it works:
- Patch via the subresource:
kubectl patch pod x --subresource resize --patch '{...}'(orkubectl edit pod x --subresource resize). A regular patch againstspec.containers[].resourcesgets rejected as immutable. - Configure per-container, per-resource
resizePolicy:restartPolicy: NotRequired(default, resize live) orRestartContainer. Pods withrestartPolicy: Neveronly allowNotRequired. - Track progress through pod conditions:
PodResizePendingwith reasonInfeasible(node can never fit it) orDeferred(waiting for space to free up), andPodResizeInProgresswhile kubelet applies it (withreason: Errorif the runtime refuses). Checkstatus.containerStatuses[].allocatedResourcesfor what's actually granted andstatus.observedGenerationto confirm kubelet processed your latest change. - Constraints to remember: CPU and memory only; QoS class is locked at pod creation (Guaranteed must stay requests == limits, Burstable can't become Guaranteed, BestEffort can't gain requests); you can't remove a request once set; shrinking memory below live usage stays In Progress; non-restartable init containers, ephemeral containers, Windows pods, and static CPU-manager pods can't resize in place.
- VPA caught up too:
updateMode: InPlaceOrRecreateis GA in VPA 1.6, resizing live whenever kubelet permits and falling back to recreation only when necessary. That eliminates the old eviction penalty for latency-sensitive apps (though the HPA conflict on the same metric still applies).
Pod-level resources
spec.resources on the Pod object itself (beta and default-on since 1.34) defines a shared resource envelope across all containers in the pod, taking precedence for scheduling and QoS. In-place resizing of pod-level budgets hit beta in 1.36. Quotas and LimitRanges count it just like container requests, so always check your cluster version before reaching for it.
Optional topology spread fields
minDomains(withDoNotSchedule): treats fewer eligible domains than this minimum as skew, nudging the autoscaler to spin up another zone rather than crowding into two.nodeAffinityPolicyandnodeTaintsPolicy(GA since 1.33): setHonororIgnoreto control whether excluded nodes count toward skew. By default Kubernetes honors affinity and ignores taints, which is why tainted spare nodes can skew your counts.matchLabelKeys(typicallypod-template-hash): spreads each ReplicaSet revision independently so rolling updates don't fight your spread rule.
HPA edge cases worth knowing
- Global tolerance defaults to 10%; per-HPA
spec.behavior.scaleUp.toleranceandscaleDown.tolerancehit GA in 1.37 (beta/off-by-default in 1.35–1.36). Verify withkubectl explain hpa.spec.behavior.scaleUpon older exam clusters before using them. - Unready pods and pods missing metrics are handled conservatively: assumed to be at 100% of target during scale-down and 0% during scale-up to dampen wild swings. CPU samples from pods ready for under 30s (
--horizontal-pod-autoscaler-initial-readiness-delay) are ignored. behavior.scaleDown.stabilizationWindowSecondsdefaults to 300 (scale-up defaults to 0); combinepoliciesviaselectPolicy: Max(default),Min, orDisabledto freeze scaling in one direction.ContainerResourcemetrics measure a single container rather than the pod sum, which is essential when heavy sidecars would otherwise distort scaling.
Before resizing a live pod, run kubectl get pod x -o jsonpath='{.status.qosClass}'. Because QoS class can never change after creation, any resize that crosses a QoS boundary fails fast with a validation error naming the exact violation.
Exercises
Create three pods in default: one with requests==limits, one with only requests, one with nothing. Predict each class before checking:
kubectl get pod <name> -o jsonpath='{.status.qosClass}{"\n"}'outputcaptured 2026-08-26
$ kubectl get pod qos-guaranteed -o jsonpath='{.status.qosClass}{"\n"}'
Guaranteed
$ kubectl get pod qos-burstable -o jsonpath='{.status.qosClass}{"\n"}'
Burstable
$ kubectl get pod qos-besteffort -o jsonpath='{.status.qosClass}{"\n"}'
BestEffortMemory first. kubectl run lost its resource flags a while back, so this is also a rep for the --overrides escape hatch:
kubectl run oom --image=polinux/stress --restart=Never \
--overrides='{"spec":{"containers":[{"name":"oom","image":"polinux/stress","command":["stress","--vm","1","--vm-bytes","128M","--vm-hang","0"],"resources":{"requests":{"memory":"64Mi"},"limits":{"memory":"64Mi"}}}]}}'
kubectl get pod oom -w # until STATUS shows OOMKilledoutputcaptured 2026-08-26
$ kubectl run oom --image=polinux/stress --restart=Never \
--overrides='{"spec":{"containers":[{"name":"oom","image":"polinux/stress","command":["stress","--vm","1","--vm-bytes","128M","--vm-hang","0"],"resources":{"requests":{"memory":"64Mi"},"limits":{"memory":"64Mi"}}}]}}'
pod/oom created
$ kubectl get pod oom -w # until STATUS shows OOMKilled
NAME READY STATUS RESTARTS AGE
oom 0/1 Pending 0 1s
oom 0/1 ContainerCreating 0 1s
oom 0/1 ContainerCreating 0 3s
oom 1/1 Running 0 12s
oom 0/1 OOMKilled 0 12s
oom 0/1 OOMKilled 0 14s
^Ckubectl get pod oom -o jsonpath='{.status.containerStatuses[0].state.terminated.reason}' prints OOMKilled. With --restart=Never nothing restarts, so the evidence sits in state, not lastState; in a crash-looping Deployment it is the other way round. CPU, by contrast, would have throttled silently.Deploy 4 replicas of anything with:
topologySpreadConstraints:
- maxSkew: 1
topologyKey: topology.kubernetes.io/zone
whenUnsatisfiable: DoNotSchedule
labelSelector: { matchLabels: { app: spread-demo } }kubectl get pods -l app=spread-demo -o wide shows 2+2 across the two worker zones, and kubectl get nodes -L topology.kubernetes.io/zone confirms which zone each node carries.Deploy examples/demo-app/base into default (kubectl apply -k examples/demo-app/base), then:
kubectl autoscale deploy demo --min=2 --max=6 --cpu-percent=20
kubectl run load --image=busybox:1.37 --restart=Never -- \
sh -c 'while true; do wget -qO- http://demo.default.svc:80 >/dev/null; done'
kubectl get hpa demo -woutputcaptured 2026-08-26
$ kubectl autoscale deploy demo --min=2 --max=6 --cpu-percent=20
Flag --cpu-percent has been deprecated, Use --cpu with percentage or resource quantity format (e.g., '70%' for utilization or '500m' for milliCPU).
horizontalpodautoscaler.autoscaling/demo autoscaled
$ kubectl run load --image=busybox:1.37 --restart=Never -- \
sh -c 'while true; do wget -qO- http://demo.default.svc:80 >/dev/null; done'
pod/load created
$ kubectl get hpa demo -w
NAME REFERENCE TARGETS MINPODS MAXPODS REPLICAS AGE
demo Deployment/demo cpu: <unknown>/20% 2 6 0 0s
demo Deployment/demo cpu: <unknown>/20% 2 6 2 15s
demo Deployment/demo cpu: 114%/20% 2 6 2 30s
demo Deployment/demo cpu: 98%/20% 2 6 4 45s
demo Deployment/demo cpu: 98%/20% 2 6 6 60s
demo Deployment/demo cpu: 34%/20% 2 6 6 75s
demo Deployment/demo cpu: 36%/20% 2 6 6 91s
demo Deployment/demo cpu: 41%/20% 2 6 6 106s
demo Deployment/demo cpu: 30%/20% 2 6 6 2m1s
demo Deployment/demo cpu: 25%/20% 2 6 6 2m16s
demo Deployment/demo cpu: 30%/20% 2 6 6 2m31s
demo Deployment/demo cpu: 39%/20% 2 6 6 2m46s
demo Deployment/demo cpu: 38%/20% 2 6 6 3m1s
demo Deployment/demo cpu: 25%/20% 2 6 6 3m16s
demo Deployment/demo cpu: 26%/20% 2 6 6 3m31s
demo Deployment/demo cpu: 38%/20% 2 6 6 3m46s
demo Deployment/demo cpu: 39%/20% 2 6 6 4m1s
demo Deployment/demo cpu: 30%/20% 2 6 6 4m16s
^Cload and watch it settle back after the stabilization window (about 5 minutes). The demo container requests 25m CPU, which is why 20% is reachable at all.With demo still running:
apiVersion: autoscaling.k8s.io/v1
kind: VerticalPodAutoscaler
metadata: { name: demo, namespace: default }
spec:
targetRef: { apiVersion: apps/v1, kind: Deployment, name: demo }
updatePolicy: { updateMode: "Off" }Give it a few minutes, then:
kubectl get vpa demo -o jsonpath='{.status.recommendation.containerRecommendations[0]}' | jqoutputcaptured 2026-08-26
$ kubectl get vpa demo -o jsonpath='{.status.recommendation.containerRecommendations[0]}' | jq
{
"containerName": "web",
"lowerBound": {
"cpu": "15m",
"memory": "100Mi"
},
"target": {
"cpu": "23m",
"memory": "100Mi"
},
"uncappedTarget": {
"cpu": "23m",
"memory": "100Mi"
},
"upperBound": {
"cpu": "12479m",
"memory": "8405796509"
}
}In-place resize changed what "change the resources" means: a CPU request can move without the container restarting. The subresource is resize, not a normal patch, and the evidence lives in status.containerStatuses[].allocatedResources. The second half of this exercise asks for more CPU than the node has, to find out where a resize you cannot have gets refused.
kubectl run burst --image=nginx:1.27-alpine --restart=Never --overrides='{"spec":{"containers":[{"name":"burst","image":"nginx:1.27-alpine","resources":{"requests":{"cpu":"100m","memory":"64Mi"},"limits":{"cpu":"200m","memory":"128Mi"}}}]}}'
kubectl wait --for=condition=Ready pod/burst --timeout=90s
kubectl get pod burst -o jsonpath='{.status.qosClass}{"\n"}'
kubectl patch pod burst --subresource resize --patch '{"spec":{"containers":[{"name":"burst","resources":{"requests":{"cpu":"200m","memory":"64Mi"},"limits":{"cpu":"400m","memory":"128Mi"}}}]}}'
kubectl get pod burst -o jsonpath='{.status.containerStatuses[0].allocatedResources}{"\n"}{.status.containerStatuses[0].restartCount}{"\n"}'
kubectl get pod burst -o jsonpath='{.status.conditions}' | jq '.[] | {type, status, reason}'
kubectl patch pod burst --subresource resize --patch '{"spec":{"containers":[{"name":"burst","resources":{"requests":{"cpu":"64","memory":"64Mi"},"limits":{"cpu":"80","memory":"128Mi"}}}]}}'
kubectl get pod burst -o jsonpath='{.status.conditions}' | jq '.[] | {type, status, reason, message}'
kubectl delete pod burstoutputcaptured 2026-11-17
$ kubectl run burst --image=nginx:1.27-alpine --restart=Never --overrides='{"spec":{"containers":[{"name":"burst","image":"nginx:1.27-alpine","resources":{"requests":{"cpu":"100m","memory":"64Mi"},"limits":{"cpu":"200m","memory":"128Mi"}}}]}}'
pod/burst created
$ kubectl wait --for=condition=Ready pod/burst --timeout=90s
pod/burst condition met
$ kubectl get pod burst -o jsonpath='{.status.qosClass}{"\n"}'
Burstable
$ kubectl patch pod burst --subresource resize --patch '{"spec":{"containers":[{"name":"burst","resources":{"requests":{"cpu":"200m","memory":"64Mi"},"limits":{"cpu":"400m","memory":"128Mi"}}}]}}'
pod/burst patched
$ kubectl get pod burst -o jsonpath='{.status.containerStatuses[0].allocatedResources}{"\n"}{.status.containerStatuses[0].restartCount}{"\n"}'
{"cpu":"200m","memory":"64Mi"}
0
$ kubectl get pod burst -o jsonpath='{.status.conditions}' | jq '.[] | {type, status, reason}'
{
"type": "PodResizeInProgress",
"status": "True",
"reason": null
}
{
"type": "PodReadyToStartContainers",
"status": "True",
"reason": null
}
{
"type": "Initialized",
"status": "True",
"reason": null
}
{
"type": "Ready",
"status": "True",
"reason": null
}
{
"type": "ContainersReady",
"status": "True",
"reason": null
}
{
"type": "PodScheduled",
"status": "True",
"reason": null
}
$ kubectl patch pod burst --subresource resize --patch '{"spec":{"containers":[{"name":"burst","resources":{"requests":{"cpu":"64","memory":"64Mi"},"limits":{"cpu":"80","memory":"128Mi"}}}]}}'
Error from server (Forbidden): pods "burst" is forbidden: node didn't have enough allocatable resources: cpu, requested: 64000, allocatable: 16000
$ kubectl get pod burst -o jsonpath='{.status.conditions}' | jq '.[] | {type, status, reason, message}'
{
"type": "PodReadyToStartContainers",
"status": "True",
"reason": null,
"message": null
}
{
"type": "Initialized",
"status": "True",
"reason": null,
"message": null
}
{
"type": "Ready",
"status": "True",
"reason": null,
"message": null
}
{
"type": "ContainersReady",
"status": "True",
"reason": null,
"message": null
}
{
"type": "PodScheduled",
"status": "True",
"reason": null,
"message": null
}
$ kubectl delete pod burst
pod "burst" deleted from default namespaceallocatedResources at {"cpu":"200m","memory":"64Mi"} and restartCount still 0. The impossible one does not park anywhere: the API refuses the patch outright with Error from server (Forbidden): pods "burst" is forbidden: node didn't have enough allocatable resources: cpu, requested: 64000, allocatable: 16000, and the pod's conditions are unchanged, with no PodResizePending among them.QoS class is computed from requests and limits and it is immutable for the life of the pod. A resize that would move a Guaranteed pod into Burstable is therefore not a scheduling problem, it is a validation error, and the message says so.
kubectl run guar --image=nginx:1.27-alpine --restart=Never --overrides='{"spec":{"containers":[{"name":"guar","image":"nginx:1.27-alpine","resources":{"requests":{"cpu":"100m","memory":"64Mi"},"limits":{"cpu":"100m","memory":"64Mi"}}}]}}'
kubectl wait --for=condition=Ready pod/guar --timeout=90s
kubectl get pod guar -o jsonpath='{.status.qosClass}{"\n"}'
kubectl patch pod guar --subresource resize --patch '{"spec":{"containers":[{"name":"guar","resources":{"requests":{"cpu":"50m","memory":"64Mi"},"limits":{"cpu":"100m","memory":"64Mi"}}}]}}'
kubectl delete pod guaroutputcaptured 2026-09-12
$ kubectl run guar --image=nginx:1.27-alpine --restart=Never --overrides='{"spec":{"containers":[{"name":"guar","image":"nginx:1.27-alpine","resources":{"requests":{"cpu":"100m","memory":"64Mi"},"limits":{"cpu":"100m","memory":"64Mi"}}}]}}'
pod/guar created
$ kubectl wait --for=condition=Ready pod/guar --timeout=90s
pod/guar condition met
$ kubectl get pod guar -o jsonpath='{.status.qosClass}{"\n"}'
Guaranteed
$ kubectl patch pod guar --subresource resize --patch '{"spec":{"containers":[{"name":"guar","resources":{"requests":{"cpu":"50m","memory":"64Mi"},"limits":{"cpu":"100m","memory":"64Mi"}}}]}}'
The Pod "guar" is invalid: spec: Invalid value: "Guaranteed": Pod QOS Class may not change as a result of resizing
$ kubectl delete pod guar
pod "guar" deleted from default namespaceA PodDisruptionBudget that can never be satisfied turns a routine node drain into a stuck terminal. Unhealthy pods count against the budget unless you tell the API otherwise.
kubectl get pdb -A -o custom-columns=NS:.metadata.namespace,NAME:.metadata.name,ALLOWED:.status.disruptionsAllowed
kubectl apply -f - <<'EOF'
apiVersion: apps/v1
kind: Deployment
metadata: { name: crasher, namespace: default }
spec:
replicas: 2
selector: { matchLabels: { app: crasher } }
template:
metadata: { labels: { app: crasher } }
spec:
nodeSelector: { kubernetes.io/hostname: cnpe-worker2 }
containers:
- name: c
image: busybox:1.36
command: ["sh", "-c", "exit 1"]
---
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata: { name: crasher, namespace: default }
spec:
minAvailable: 100%
selector: { matchLabels: { app: crasher } }
EOF
sleep 30
# --pod-selector keeps the drain to this exercise's pods; without it you evict the lab off this node
kubectl get pdb crasher -o jsonpath='{.status.disruptionsAllowed}{"\n"}'
kubectl drain cnpe-worker2 --pod-selector app=crasher --ignore-daemonsets --delete-emptydir-data --timeout=60s
kubectl patch pdb crasher --type merge -p '{"spec":{"unhealthyPodEvictionPolicy":"AlwaysAllow"}}'
kubectl drain cnpe-worker2 --pod-selector app=crasher --ignore-daemonsets --delete-emptydir-data --timeout=60s
kubectl uncordon cnpe-worker2
kubectl delete deployment crasher
kubectl delete pdb crasheroutputcaptured 2026-09-13
$ kubectl get pdb -A -o custom-columns=NS:.metadata.namespace,NAME:.metadata.name,ALLOWED:.status.disruptionsAllowed
NS NAME ALLOWED
gatekeeper-system gatekeeper-controller-manager 0
team-a pg-primary 0
tracing otel-collector 1
$ kubectl apply -f - <<'EOF'
apiVersion: apps/v1
kind: Deployment
metadata: { name: crasher, namespace: default }
spec:
replicas: 2
selector: { matchLabels: { app: crasher } }
template:
metadata: { labels: { app: crasher } }
spec:
nodeSelector: { kubernetes.io/hostname: cnpe-worker2 }
containers:
- name: c
image: busybox:1.36
command: ["sh", "-c", "exit 1"]
---
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata: { name: crasher, namespace: default }
spec:
minAvailable: 100%
selector: { matchLabels: { app: crasher } }
EOF
deployment.apps/crasher created
poddisruptionbudget.policy/crasher created
$ sleep 30
$ # --pod-selector keeps the drain to this exercise's pods; without it you evict the lab off this node
$ kubectl get pdb crasher -o jsonpath='{.status.disruptionsAllowed}{"\n"}'
0
$ kubectl drain cnpe-worker2 --pod-selector app=crasher --ignore-daemonsets --delete-emptydir-data --timeout=60s
node/cnpe-worker2 cordoned
evicting pod default/crasher-7857b795db-hbpzj
evicting pod default/crasher-7857b795db-854th
error when evicting pods/"crasher-7857b795db-hbpzj" -n "default" (will retry after 5s): Cannot evict pod as it would violate the pod's disruption budget.
error when evicting pods/"crasher-7857b795db-854th" -n "default" (will retry after 5s): Cannot evict pod as it would violate the pod's disruption budget.
evicting pod default/crasher-7857b795db-hbpzj
error when evicting pods/"crasher-7857b795db-hbpzj" -n "default" (will retry after 5s): Cannot evict pod as it would violate the pod's disruption budget.
evicting pod default/crasher-7857b795db-854th
error when evicting pods/"crasher-7857b795db-854th" -n "default" (will retry after 5s): Cannot evict pod as it would violate the pod's disruption budget.
evicting pod default/crasher-7857b795db-hbpzj
error when evicting pods/"crasher-7857b795db-hbpzj" -n "default" (will retry after 5s): Cannot evict pod as it would violate the pod's disruption budget.
evicting pod default/crasher-7857b795db-854th
error when evicting pods/"crasher-7857b795db-854th" -n "default" (will retry after 5s): Cannot evict pod as it would violate the pod's disruption budget.
evicting pod default/crasher-7857b795db-hbpzj
error when evicting pods/"crasher-7857b795db-hbpzj" -n "default" (will retry after 5s): Cannot evict pod as it would violate the pod's disruption budget.
evicting pod default/crasher-7857b795db-854th
error when evicting pods/"crasher-7857b795db-854th" -n "default" (will retry after 5s): Cannot evict pod as it would violate the pod's disruption budget.
evicting pod default/crasher-7857b795db-hbpzj
evicting pod default/crasher-7857b795db-854th
error when evicting pods/"crasher-7857b795db-hbpzj" -n "default" (will retry after 5s): Cannot evict pod as it would violate the pod's disruption budget.
error when evicting pods/"crasher-7857b795db-854th" -n "default" (will retry after 5s): Cannot evict pod as it would violate the pod's disruption budget.
evicting pod default/crasher-7857b795db-hbpzj
evicting pod default/crasher-7857b795db-854th
error when evicting pods/"crasher-7857b795db-hbpzj" -n "default" (will retry after 5s): Cannot evict pod as it would violate the pod's disruption budget.
error when evicting pods/"crasher-7857b795db-854th" -n "default" (will retry after 5s): Cannot evict pod as it would violate the pod's disruption budget.
evicting pod default/crasher-7857b795db-hbpzj
evicting pod default/crasher-7857b795db-854th
error when evicting pods/"crasher-7857b795db-854th" -n "default" (will retry after 5s): Cannot evict pod as it would violate the pod's disruption budget.
error when evicting pods/"crasher-7857b795db-hbpzj" -n "default" (will retry after 5s): Cannot evict pod as it would violate the pod's disruption budget.
evicting pod default/crasher-7857b795db-854th
evicting pod default/crasher-7857b795db-hbpzj
error when evicting pods/"crasher-7857b795db-854th" -n "default" (will retry after 5s): Cannot evict pod as it would violate the pod's disruption budget.
error when evicting pods/"crasher-7857b795db-hbpzj" -n "default" (will retry after 5s): Cannot evict pod as it would violate the pod's disruption budget.
evicting pod default/crasher-7857b795db-854th
evicting pod default/crasher-7857b795db-hbpzj
error when evicting pods/"crasher-7857b795db-854th" -n "default" (will retry after 5s): Cannot evict pod as it would violate the pod's disruption budget.
error when evicting pods/"crasher-7857b795db-hbpzj" -n "default" (will retry after 5s): Cannot evict pod as it would violate the pod's disruption budget.
evicting pod default/crasher-7857b795db-854th
evicting pod default/crasher-7857b795db-hbpzj
error when evicting pods/"crasher-7857b795db-hbpzj" -n "default" (will retry after 5s): Cannot evict pod as it would violate the pod's disruption budget.
... 19 more lines
$ kubectl patch pdb crasher --type merge -p '{"spec":{"unhealthyPodEvictionPolicy":"AlwaysAllow"}}'
poddisruptionbudget.policy/crasher patched
$ kubectl drain cnpe-worker2 --pod-selector app=crasher --ignore-daemonsets --delete-emptydir-data --timeout=60s
node/cnpe-worker2 already cordoned
evicting pod default/crasher-7857b795db-hbpzj
evicting pod default/crasher-7857b795db-854th
pod/crasher-7857b795db-854th evicted
pod/crasher-7857b795db-hbpzj evicted
node/cnpe-worker2 drained
$ kubectl uncordon cnpe-worker2
node/cnpe-worker2 uncordoned
$ kubectl delete deployment crasher
deployment.apps "crasher" deleted from default namespace
$ kubectl delete pdb crasher
poddisruptionbudget.policy "crasher" deleted from default namespacedisruptionsAllowed is 0, and the first drain refuses both pods with Cannot evict pod as it would violate the pod's disruption budget until it times out. After unhealthyPodEvictionPolicy: AlwaysAllow the same command evicts both and prints node/cnpe-worker2 drained. Note the --pod-selector: without it this drain empties the node, and half the lab is on it.Allocatable is capacity minus what the kubelet reserved, and the reservation is a kubelet flag rather than anything in the API. Read both halves on the same node so the subtraction is yours, not a slide's.
kubectl get node cnpe-worker -o jsonpath='{"capacity: cpu "}{.status.capacity.cpu}{", memory "}{.status.capacity.memory}{"\n"}{"allocatable: cpu "}{.status.allocatable.cpu}{", memory "}{.status.allocatable.memory}{"\n"}'
kubectl get --raw /api/v1/nodes/cnpe-worker/proxy/configz | jq '.kubeletconfig | {kubeReserved, systemReserved, evictionHard}'
kubectl describe node cnpe-worker | sed -n '/Allocated resources/,/Events/p'outputcaptured 2026-09-13
$ kubectl get node cnpe-worker -o jsonpath='{"capacity: cpu "}{.status.capacity.cpu}{", memory "}{.status.capacity.memory}{"\n"}{"allocatable: cpu "}{.status.allocatable.cpu}{", memory "}{.status.allocatable.memory}{"\n"}'
capacity: cpu 16, memory 32747836Ki
allocatable: cpu 16, memory 32747836Ki
$ kubectl get --raw /api/v1/nodes/cnpe-worker/proxy/configz | jq '.kubeletconfig | {kubeReserved, systemReserved, evictionHard}'
{
"kubeReserved": null,
"systemReserved": null,
"evictionHard": {
"imagefs.available": "0%",
"nodefs.available": "0%",
"nodefs.inodesFree": "0%"
}
}
$ kubectl describe node cnpe-worker | sed -n '/Allocated resources/,/Events/p'
Allocated resources:
(Total limits may be over 100 percent, i.e., overcommitted.)
Resource Requests Limits
-------- -------- ------
cpu 1811m (11%) 9450m (59%)
memory 3714Mi (11%) 12800Mi (40%)
ephemeral-storage 0 (0%) 0 (0%)
hugepages-1Gi 0 (0%) 0 (0%)
hugepages-2Mi 0 (0%) 0 (0%)
Events:kubeReserved and systemReserved both read null and evictionHard is 0% on every signal, so there is no gap to subtract. The scheduler adds pod requests up against Allocatable, which is the number the Allocated resources block takes its percentages from.Two priority classes at the same value behave completely differently if one sets preemptionPolicy: Never. Batch work usually wants that: high enough to jump the scheduling queue, never rude enough to evict a neighbor.
kubectl create priorityclass batch --value=1000 --preemption-policy=Never
kubectl create priorityclass urgent --value=1000
kubectl run filler --image=nginx:1.27-alpine --restart=Never --overrides='{"spec":{"nodeSelector":{"kubernetes.io/hostname":"cnpe-worker2"},"containers":[{"name":"filler","image":"nginx:1.27-alpine","resources":{"requests":{"cpu":"12"}}}]}}'
kubectl wait --for=condition=Ready pod/filler --timeout=120s
kubectl run batchpod --image=nginx:1.27-alpine --restart=Never --overrides='{"spec":{"priorityClassName":"batch","nodeSelector":{"kubernetes.io/hostname":"cnpe-worker2"},"containers":[{"name":"batchpod","image":"nginx:1.27-alpine","resources":{"requests":{"cpu":"8"}}}]}}'
sleep 20
kubectl get pod batchpod -o wide
kubectl describe pod batchpod | tail -4
kubectl run urgentpod --image=nginx:1.27-alpine --restart=Never --overrides='{"spec":{"priorityClassName":"urgent","nodeSelector":{"kubernetes.io/hostname":"cnpe-worker2"},"containers":[{"name":"urgentpod","image":"nginx:1.27-alpine","resources":{"requests":{"cpu":"8"}}}]}}'
sleep 30
kubectl get pods filler batchpod urgentpod -o wide
kubectl delete pod filler batchpod urgentpod --ignore-not-found
kubectl delete priorityclass batch urgentoutputcaptured 2026-11-18
$ kubectl create priorityclass batch --value=1000 --preemption-policy=Never
priorityclass.scheduling.k8s.io/batch created
$ kubectl create priorityclass urgent --value=1000
priorityclass.scheduling.k8s.io/urgent created
$ kubectl run filler --image=nginx:1.27-alpine --restart=Never --overrides='{"spec":{"nodeSelector":{"kubernetes.io/hostname":"cnpe-worker2"},"containers":[{"name":"filler","image":"nginx:1.27-alpine","resources":{"requests":{"cpu":"12"}}}]}}'
pod/filler created
$ kubectl wait --for=condition=Ready pod/filler --timeout=120s
pod/filler condition met
$ kubectl run batchpod --image=nginx:1.27-alpine --restart=Never --overrides='{"spec":{"priorityClassName":"batch","nodeSelector":{"kubernetes.io/hostname":"cnpe-worker2"},"containers":[{"name":"batchpod","image":"nginx:1.27-alpine","resources":{"requests":{"cpu":"8"}}}]}}'
pod/batchpod created
$ sleep 20
$ kubectl get pod batchpod -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
batchpod 0/1 Pending 0 20s <none> <none> <none> <none>
$ kubectl describe pod batchpod | tail -4
Type Reason Age From Message
---- ------ ---- ---- -------
Warning PolicyViolation 21s kyverno-admission policy require-resource-requests/validation fail: every container must set cpu and memory requests
Warning FailedScheduling 21s default-scheduler 0/3 nodes are available: 1 Insufficient cpu, 1 node(s) didn't match Pod's node affinity/selector, 1 node(s) had untolerated taint(s). preemption: not eligible due to preemptionPolicy=Never.
$ kubectl run urgentpod --image=nginx:1.27-alpine --restart=Never --overrides='{"spec":{"priorityClassName":"urgent","nodeSelector":{"kubernetes.io/hostname":"cnpe-worker2"},"containers":[{"name":"urgentpod","image":"nginx:1.27-alpine","resources":{"requests":{"cpu":"8"}}}]}}'
pod/urgentpod created
$ sleep 30
$ kubectl get pods filler batchpod urgentpod -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
batchpod 0/1 Pending 0 52s <none> <none> <none> <none>
urgentpod 1/1 Running 0 31s 10.244.1.209 cnpe-worker2 <none> <none>
Error from server (NotFound): pods "filler" not found
$ kubectl delete pod filler batchpod urgentpod --ignore-not-found
pod "batchpod" deleted from default namespace
pod "urgentpod" deleted from default namespace
$ kubectl delete priorityclass batch urgent
priorityclass.scheduling.k8s.io "batch" deleted
priorityclass.scheduling.k8s.io "urgent" deletedbatchpod stays Pending with an Insufficient cpu event and nothing is evicted, while urgentpod at the same value takes the room by pushing filler out. The two classes carry the same value; only preemptionPolicy differs.An HPA created with one command still has a full scale-up and scale-down policy; you just did not type it. Know where the defaults live before a task asks you to slow a flapping scale-down.
kubectl create deployment hpademo --image=nginx:1.27-alpine
kubectl set resources deployment hpademo --requests=cpu=50m
kubectl autoscale deployment hpademo --cpu-percent=80 --min=1 --max=5
kubectl get hpa hpademo -o jsonpath='{.spec.behavior}{"\n"}'
kubectl get hpa hpademo -o yaml | sed -n '/^spec:/,/^status:/p'
kubectl explain hpa.spec.behavior.scaleDown
kubectl delete hpa hpademo
kubectl delete deployment hpademooutputcaptured 2026-11-18
$ kubectl create deployment hpademo --image=nginx:1.27-alpine
deployment.apps/hpademo created
$ kubectl set resources deployment hpademo --requests=cpu=50m
deployment.apps/hpademo resource requirements updated
$ kubectl autoscale deployment hpademo --cpu-percent=80 --min=1 --max=5
Flag --cpu-percent has been deprecated, Use --cpu with percentage or resource quantity format (e.g., '70%' for utilization or '500m' for milliCPU).
horizontalpodautoscaler.autoscaling/hpademo autoscaled
$ kubectl get hpa hpademo -o jsonpath='{.spec.behavior}{"\n"}'
$ kubectl get hpa hpademo -o yaml | sed -n '/^spec:/,/^status:/p'
spec:
maxReplicas: 5
metrics:
- resource:
name: cpu
target:
averageUtilization: 80
type: Utilization
type: Resource
minReplicas: 1
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: hpademo
status:
$ kubectl explain hpa.spec.behavior.scaleDown
GROUP: autoscaling
KIND: HorizontalPodAutoscaler
VERSION: v2
FIELD: scaleDown <HPAScalingRules>
DESCRIPTION:
scaleDown is scaling policy for scaling Down. If not set, the default value
is to allow to scale down to minReplicas pods, with a 300 second
stabilization window (i.e., the highest recommendation for the last 300sec
is used).
HPAScalingRules configures the scaling behavior for one direction via
scaling Policy Rules and a configurable metric tolerance.
Scaling Policy Rules are applied after calculating DesiredReplicas from
metrics for the HPA. They can limit the scaling velocity by specifying
scaling policies. They can prevent flapping by specifying the stabilization
window, so that the number of replicas is not set instantly, instead, the
safest value from the stabilization window is chosen.
The tolerance is applied to the metric values and prevents scaling too
eagerly for small metric variations.
FIELDS:
policies <[]HPAScalingPolicy>
policies is a list of potential scaling polices which can be used during
scaling. If not set, use the default values: - For scale up: allow doubling
the number of pods, or an absolute change of 4 pods in a 15s window. - For
scale down: allow all pods to be removed in a 15s window.
selectPolicy <string>
selectPolicy is used to specify which policy should be used. If not set, the
default value Max is used.
stabilizationWindowSeconds <integer>
stabilizationWindowSeconds is the number of seconds for which past
recommendations should be considered while scaling up or scaling down.
StabilizationWindowSeconds must be greater than or equal to zero and less
... 14 more lines
$ kubectl delete hpa hpademo
horizontalpodautoscaler.autoscaling "hpademo" deleted from default namespace
$ kubectl delete deployment hpademo
deployment.apps "hpademo" deleted from default namespacespec.behavior reads back empty, the defaults are the controller's rather than the object's, and that is the answer to give.Self-check
A node shows 25% CPU usage and refuses to schedule a pod requesting 200m. Explain, in one sentence.
The scheduler checks pod requests against allocatable capacity, never live usage, so the node's CPU requests are already maxed out even though the running pods are mostly idle. Fix it by right-sizing inflated requests (or adding nodes).
Which pod does the kubelet evict first under memory pressure, and why?
BestEffort goes first because it declared no memory request at all. Next are Burstable pods exceeding their requests, ordered by how far over they are, with Guaranteed pods last. The kernel's oom_score_adj mirrors that exact ranking so node-level OOMs choose the same victim.
Your service has p99 latency spikes every few seconds; CPU usage sits at 60% of the limit. First metric you check?
Check rate(container_cpu_cfs_throttled_periods_total[5m]). A comfortable 60% average hides bursty per-period throttling: the container burns its 100ms CFS quota early and freezes until the next period starts.
Why can a VPA in Auto mode and an HPA on CPU not coexist on the same workload?
They fight in a feedback loop: HPA scales replicas off usage divided by requests while VPA keeps rewriting those requests underneath it. The clean fix is running HPA on CPU with VPA in Off (advisory) mode, or driving HPA from a custom/external metric while VPA manages CPU/memory.
A drain hangs forever on one node. What are the two usual causes?
Either a PodDisruptionBudget with zero allowed disruptions (like minAvailable equal to total replicas), or unmanaged bare pods with no controller that kubectl drain refuses to evict unless you pass --force.
Is in-place pod resize usable on a Kubernetes 1.37 cluster, and what does the request look like?
Yes: InPlacePodVerticalScaling hit GA in 1.35 (beta/default-on in 1.33). Patch through the resize subresource (kubectl patch pod x --subresource resize ...), since plain spec patches are rejected as immutable. Watch PodResizePending (Infeasible / Deferred) and PodResizeInProgress conditions, and remember QoS class can never change.
Karpenter refuses to consolidate a node you consider empty enough. Where is the reason, and name two things it could be.
Look for Unconsolidatable events on the node. Common blockers include a restrictive PDB, a pod carrying karpenter.sh/do-not-disrupt, no cheaper instance replacement available, or an exhausted NodePool disruption budget (Cluster Autoscaler has analogous blockers like safe-to-evict: "false", bare pods, and local storage).
A PDB has minAvailable 2 for a 2-replica Deployment whose pods are CrashLoopBackOff. Drain hangs. Fix without deleting the PDB?
Patch the PDB with unhealthyPodEvictionPolicy: AlwaysAllow. The default IfHealthyBudget refuses to evict even unhealthy pods while the budget isn't met, deadlocking the drain. Alternatively, scale the Deployment up temporarily, since deleting the PDB strips protection permanently.
What is allocatable, and which four kubelet settings subtract from capacity?
Allocatable is the slice of node capacity available for scheduling pods: total capacity minus kubeReserved, systemReserved, and evictionHard thresholds (defaults: memory.available 100Mi, nodefs.available 10%, nodefs.inodesFree 5%, imagefs.available 15%). enforceNodeAllocatable chooses which cgroups are enforced (default: pods).
Docs to know your way around
- kubernetes.io: Resource Management for Pods and Containers; Pod Quality of Service Classes; Node-pressure Eviction; Assigning Pods to Nodes; Pod Topology Spread Constraints; the HorizontalPodAutoscaler walkthrough (the algorithm section especially).
- github.com/kubernetes/autoscaler: the VPA README, in particular the
updateModetable. - Offline:
kubectl explain pod.spec.containers.resources,kubectl explain hpa.spec.behavior --recursive, and the requests table at the bottom ofkubectl describe node. - kubernetes.io/docs/tasks/configure-pod-container/resize-container-resources: the resize subresource, resizePolicy, and the PodResizePending / PodResizeInProgress conditions with their reasons.
- kubernetes.io/docs/concepts/cluster-administration/node-autoscaling: the neutral Cluster Autoscaler vs Karpenter comparison; karpenter.sh/docs/concepts/disruption for consolidationPolicy, budgets and do-not-disrupt.
- kubernetes.io/docs/tasks/administer-cluster/reserve-compute-resources: kubeReserved, systemReserved, evictionHard and enforceNodeAllocatable with the worked allocatable example.