Skip to main content
In this lesson you will inspect and fix resource requests and limits for pods in Kubernetes. The lab sequence:
  1. Inspect the rabbit pod to find its CPU request, then delete the pod.
  2. Inspect the elephant pod to discover why it is failing.
  3. Increase the elephant pod memory limit and recreate it so it runs.
  4. Clean up by deleting the pod when finished.

Task 1 — Identify CPU request on the rabbit pod

Inspect the rabbit pod to determine its CPU request:
Relevant excerpt from the describe output:
The CPU request for the rabbit pod is 1 CPU. To remove the rabbit pod:

Task 2 — Why is the elephant pod not running?

Describe the elephant pod to find why it is failing:
Relevant excerpt showing the container state and resource configuration:
Diagnosis:
  • 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 is 10Mi. This mismatch causes the OOMKill.
Action required:
  • 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. Using kubectl edit pod to change resource limits will usually fail with an error like:
You might try to change the manifest to:
But saving the edit can return:
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>).
Recommended procedure
  1. Export the existing pod manifest to a file (or save the temporary file from kubectl edit) and modify the resources block so limits contain memory: 20Mi.
    • Example filename: /tmp/elephant-pod.yaml
  2. Replace the pod using a forced replace, which deletes and recreates the pod with the new manifest:
Example output:
Verify the pod is running:
Example output:
Confirm the memory limit is now 20Mi:
Relevant excerpt:
The pod is now running with the updated memory limit.

Task 4 — Clean up

When finished, delete the elephant pod:
Example output:

Quick reference: common kubectl commands used


Summary

  • Inspected the rabbit pod and confirmed its CPU request was 1 CPU, then deleted the pod.
  • Diagnosed the elephant pod failure: OOMKilled due to a container allocating 15M while the pod limit was 10Mi.
  • Updated the pod by editing its manifest and using kubectl replace --force to recreate the pod with memory: 20Mi.
  • Verified the pod runs and cleaned up.
Links and references

Watch Video