0
0
Kubernetesdevops~30 mins

OOMKilled containers in Kubernetes - Mini Project: Build & Apply

Choose your learning style9 modes available
Understanding and Handling OOMKilled Containers in Kubernetes
📖 Scenario: You are managing a Kubernetes cluster running several containers. Some containers are unexpectedly stopping with the status OOMKilled, which means they ran out of memory and were terminated by the system.Your task is to identify these containers, set memory limits to prevent this, and verify the changes.
🎯 Goal: Learn how to detect OOMKilled containers, configure memory limits in pod specs, and confirm the containers run without being killed due to memory issues.
📋 What You'll Learn
Use kubectl commands to check pod status
Edit pod resource limits to set memory limits
Apply changes and verify pod status
Understand the meaning of OOMKilled in pod status
💡 Why This Matters
🌍 Real World
In real Kubernetes clusters, containers can be terminated if they use more memory than allowed. Setting memory limits helps keep the cluster stable and prevents one container from affecting others.
💼 Career
DevOps engineers and site reliability engineers often troubleshoot OOMKilled containers and configure resource limits to ensure applications run reliably in Kubernetes.
Progress0 / 4 steps
1
Check for OOMKilled containers
Run the command kubectl get pods to list all pods and then run kubectl describe pod myapp-pod to check the status of the pod named myapp-pod. Look for the term OOMKilled in the container status section.
Kubernetes
Need a hint?

Use kubectl describe pod myapp-pod to see detailed container status including termination reasons.

2
Add memory limits to the pod configuration
Edit the pod configuration file myapp-pod.yaml to add a memory limit of 200Mi under resources.limits.memory for the container named myapp-container.
Kubernetes
Need a hint?

Under the container spec, add resources: with limits: and set memory: "200Mi".

3
Apply the updated pod configuration
Run the command kubectl apply -f myapp-pod.yaml to update the pod with the new memory limits.
Kubernetes
Need a hint?

Use kubectl apply -f myapp-pod.yaml to update the pod with your changes.

4
Verify the pod is running without OOMKilled status
Run kubectl get pods and kubectl describe pod myapp-pod again to confirm the pod is running and the container status does not show OOMKilled.
Kubernetes
Need a hint?

Look for Status: Running and absence of OOMKilled in the container status.