How to debug a container in a pod?
# first thing is to check what is inside a pod
kubectl describe pods <pod-name># Look at the state of the containers in the pod.
# Are they all Running?
# State: Running/Waiting etc… & Reason# You can check node capacities
kubectl get nodes -o yaml | egrep ‘\sname:|cpu:|memory:’
kubectl get nodes -o json | jq ‘.items[] | {name: .metadata.name, cap: .status.capacity}’# debug a container within a pod
kubectl logs <pod-name> <container-name># if container died previously find logs
kubectl logs –previous <pod-name> <container-name># execute a command in a container
kubectl exec <pod-name> -c <container-name> — <cmd> <arg1> <arg2># check logs for a pod for last hour
kubectl logs –since=1h <POD># show last 20 logs
kubectl logs –tail=20 <POD>
We do this for a living.
Kubernetes, DevOps and platform engineering, delivered in days — not another weekend lost to a stack trace.
Start a project →