Kubernetes Node Swap Enablement & Config Prompt
Safely enable NodeSwap with the LimitedSwap behavior, size swap per node, and set cgroup v2 memory.swap limits so Burstable pods get headroom without thrashing Guaranteed pods.
- Target user
- Node and cluster operators evaluating swap on Kubernetes
- Difficulty
- Advanced
- Tools
- Claude, ChatGPT
The prompt
You are a senior Kubernetes node engineer who has enabled swap on production nodes and knows that the kubelet's `LimitedSwap` only grants swap to Burstable QoS pods on cgroup v2, that Guaranteed and BestEffort pods get none, and that mis-sized swap causes latency cliffs. I will provide: - My node OS, kernel, container runtime, and whether the nodes are on cgroup v2 - My workload mix (which pods are Guaranteed vs Burstable) and the problem I'm solving (memory spikes, eviction storms) - How much physical RAM and disk the nodes have Your job: 1. **Confirm prerequisites** — verify cgroup v2, kernel swap support, and the kubelet feature/config needed; state that swap is ignored on cgroup v1 setups. 2. **Configure the kubelet** — write the KubeletConfiguration `memorySwap.swapBehavior: LimitedSwap` and explain how per-pod swap is derived from the pod's memory request vs node capacity. 3. **Size the swap** — recommend swap size relative to RAM for the workload, and warn that too much swap on slow disk turns OOM into unbounded latency. 4. **Explain QoS interaction** — make explicit that only Burstable pods get swap under LimitedSwap; Guaranteed pods are protected, BestEffort get nothing. 5. **Plan the rollout** — cordon/drain one node, enable swap, soak under load, then expand, with metrics (swap-in/out rate, p99 latency) to watch. 6. **Set guardrails** — eviction thresholds and monitoring so a swap-thrashing node is detected and drained before it degrades the service. Output as: (a) the node OS swap setup commands, (b) the KubeletConfiguration snippet, and (c) a rollout runbook with the metrics and eviction thresholds to watch. Mark DESTRUCTIVE enabling swap on a running node without drain, and any swap setup on latency-critical Guaranteed workloads where swap-in stalls violate SLOs.
Run this prompt with AI
Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.
Related prompts
-
Kubernetes Memory QoS with cgroup v2 Tuning Prompt
Tune Memory QoS (memory.min / memory.high via cgroup v2) so latency-sensitive pods get protected reclaim guarantees and bursty pods are throttled before an OOM kill — instead of relying only on hard limits and reactive OOMKilled restarts.
-
Kubernetes Image GC and Disk Pressure Tuning Prompt
Tune kubelet image garbage collection and eviction thresholds to stop DiskPressure node taints, image-pull churn, and evictions caused by a full image/container filesystem.
-
Kubernetes OOMKilled Memory Limit Diagnosis Prompt
Diagnose why containers are OOMKilled — distinguish container limit kills from node-level memory pressure, working-set growth, and JVM/heap-vs-RSS gaps, then right-size limits.
-
Kubernetes Kubelet Certificate Rotation & CSR Debug Prompt
Debug kubelet client/serving certificate rotation failures and stuck CertificateSigningRequests that leave nodes NotReady or unable to authenticate — restoring rotation without manually minting risky long-lived certs.
More Kubernetes & Helm prompts & error guides
Browse every Kubernetes & Helm prompt and troubleshooting guide in one place.
Reading prompts? Get all 500 in one free PDF
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.