- Inspect the
rabbitpod to find its CPU request, then delete the pod. - Inspect the
elephantpod to discover why it is failing. - Increase the
elephantpod memory limit and recreate it so it runs. - Clean up by deleting the pod when finished.
Task 1 — Identify CPU request on the rabbit pod
Inspect therabbit pod to determine its CPU request:
rabbit pod is 1 CPU.
To remove the rabbit pod:
Task 2 — Why is the elephant pod not running?
Describe theelephant pod to find why it is failing:
- The container was
OOMKilled(last state), which means it exceeded its memory limit. - The container is configured to allocate
15M(--vm-bytes 15M), but the pod’s memory limit is10Mi. This mismatch causes the OOMKill.
- Increase the memory limit so it is larger than the memory the container will allocate. For safety, set the limit to at least
20Mi.
Task 3 — Update the elephant pod’s memory limit to 20Mi
Important: pod fields such as resource limits are effectively immutable after pod creation. Usingkubectl edit pod to change resource limits will usually fail with an error like:
Pods are mostly immutable. To change fields like resource limits, export the pod manifest, modify it offline, then recreate the pod (delete and re-create or use
kubectl replace --force -f <file>).- Export the existing pod manifest to a file (or save the temporary file from
kubectl edit) and modify theresourcesblock so limits containmemory: 20Mi.- Example filename:
/tmp/elephant-pod.yaml
- Example filename:
- Replace the pod using a forced replace, which deletes and recreates the pod with the new manifest:
20Mi:
Task 4 — Clean up
When finished, delete theelephant pod:
Quick reference: common kubectl commands used
Summary
- Inspected the
rabbitpod and confirmed its CPU request was1CPU, then deleted the pod. - Diagnosed the
elephantpod failure:OOMKilleddue to a container allocating15Mwhile the pod limit was10Mi. - Updated the pod by editing its manifest and using
kubectl replace --forceto recreate the pod withmemory: 20Mi. - Verified the pod runs and cleaned up.
- Kubernetes: Resource Management for Pods and Containers
- kubectl reference
- Understanding OOMKilled in Kubernetes