Skip to main content
In this article, we review how to inspect and modify resource limits and requests for Kubernetes pods. The guide demonstrates troubleshooting techniques for resource constraints by using two example pods: “rabbit” and “elephant”. For more details on Kubernetes resource management, check out the Kubernetes Documentation.

Inspecting the “rabbit” Pod

We start by inspecting a pod named “rabbit” to identify its CPU request specifications.
  1. List the pods to verify that “rabbit” exists:
  2. Use the describe command to retrieve detailed information about the pod:
Within the output, locate the container’s resource specifications. You should see a section similar to this, which highlights the CPU limits and requests:
From the output, it is evident that the CPU request is set to “1”.
Next, delete the “rabbit” pod since it is no longer needed:
The image shows a terminal window displaying Kubernetes pod events and conditions, with instructions to delete the "rabbit" pod on the left side.

Troubleshooting the “elephant” Pod

Let’s inspect another pod called “elephant” that is failing to reach a running state.
  1. List the pods:
    The output displays:
  2. Describe the pod to understand why it is not running:
In the “Last State” section, you may notice that the container was terminated due to an out-of-memory (OOM) error. Although the pod’s memory limit is set around 1010 Mi (or similar), the process inside the pod consumes 15 Mi, causing it to exceed the allowed amount.
To resolve this issue, you must update the pod specification to allocate more memory. In this example, increasing the memory limit to 20 Mi should suffice.

Updating the Memory Limit for the “elephant” Pod

Edit the “elephant” pod using the following command:
Locate the container’s resources section and update it to resemble the configuration below:
After saving your changes, you may encounter an error like this:
Changing resource limits on a running pod is not supported. Your updates have been saved to a temporary file (/tmp/kubectl-edit-3376288381.yaml) instead.
To apply your changes, use the replace command, which will delete the existing pod and recreate it with the updated configuration:
After executing the replace command, verify that the “elephant” pod is now running and that the new memory limit is in effect:
If needed, delete the pod again after validation, allowing a few seconds for the process to terminate.
The image shows a Kubernetes YAML configuration for a pod named "elephant," with instructions to increase its memory limit to 20Mi.

Conclusion

This lab demonstrated how to inspect and update resource limits in Kubernetes pods. You learned to verify CPU and memory settings using the describe command, diagnose issues like CrashLoopBackOff and OOM errors, and apply changes through the replace command. For further reading on resource management in Kubernetes, visit the Kubernetes Basics. Happy Kubernetes troubleshooting!

Watch Video