This article provides solutions for verifying CPU requirements and troubleshooting memory issues in Kubernetes pods.
In this lesson, we will walk through the solutions for the resource limits lab. Follow the steps below to verify CPU requirements for the “rabbit” pod, troubleshoot the “elephant” pod, and update its memory configuration.
Question 1: Verifying CPU Requirements for the “rabbit” Pod
A pod named rabbit is deployed, and our task is to determine its CPU settings. Run the following command to describe the pod:
Copy
Ask AI
kubectl describe pod rabbit
Scroll through the output until you find the resources section. You should see details such as:
Copy
Ask AI
Exit Code: 128Started: Thu, 01 Jan 1970 00:00:00 +0000Finished: Tue, 02 Aug 2022 17:24:15 +0000Ready: FalseRestart Count: 5Limits: cpu: 2Requests: cpu: 1Environment: <none>Mounts: /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-27zq6 (ro)Conditions: Type Status Initialized True Ready False ContainersReady False PodScheduled TrueVolumes: kube-api-access-27zq6: Type: Projected (a volume that contains injected data from multiple sources) TokenExpirationSeconds: 3607 ConfigMapName: kube-root-ca.crt ConfigMapOptional: <nil> DownwardAPI: trueQoS Class: BurstableNode-Selectors: <none>Tolerations: node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
From the above information, notice that the CPU request is set to 1 while the limit is 2. This indicates that the pod is configured to run with one CPU.After verification, delete the rabbit pod with the command:
The OOMKilled status indicates the pod was terminated because it ran out of memory. The pod has a memory limit set at 10Mi, but its process needs 15 MB.
Edit the YAML ConfigurationOpen the elephant.yaml file using your favorite text editor (e.g., vi):
Copy
Ask AI
controlplane ~ ➜ vi elephant.yaml
Locate the section specifying the memory limits and update it from 10Mi to 20Mi.
Apply the Updated ConfigurationRecreate the pod by applying the modified YAML file:
Copy
Ask AI
controlplane ~ ➜ kubectl apply -f elephant.yamlpod/elephant created
Verify the Pod StatusCheck to ensure the pod is running:
Copy
Ask AI
controlplane ~ ➜ kubectl get podNAME READY STATUS RESTARTS AGEelephant 1/1 Running 0 13scontrolplane ~ ➜ []
Final DeletionOnce verified, delete the elephant pod as the lab instructions specify:
Copy
Ask AI
controlplane ~ ➜ kubectl delete pod elephant
After completing these steps and confirming that the pod eventually reaches a running state, you have successfully completed the resource limits lab.This concludes the Resource Limits Lab Solutions lesson.