🎓 A1Learner
🔍
0 of 51 lessons completed

Kubernetes: Read a Pod

kubectl describe is the command that shows what a Pod is doing. It reads one Pod field by field, from its image down to its events.

Start with the short status

get pods shows the name, the ready count and the status. It hides the reason behind the status.

kubectl get pods

Read the Pod in full

describe shows the node, the image and the events. The events tell the story of the Pod so far.

kubectl describe pod web-pod

Read what the container printed

logs reads the output of the container inside the Pod. It shows what the app itself did.

kubectl logs web-pod

Read the logs of a crashed container

A crashed container leaves no current logs. The previous logs hold the error that killed it.

kubectl logs web-pod --previous

Example

kubectl get pods
kubectl describe pod web-pod
kubectl logs web-pod

Key points

  • Use kubectl get pods to see the short status of every Pod.
  • Use kubectl describe pod to see one Pod in full detail.
  • Events: short notes Kubernetes keeps about what happened to a Pod.
  • Use kubectl logs to read what the container itself printed.
  • Use kubectl logs --previous to read the logs of a container that crashed.
  • A Pod name is unique inside its namespace, so describe needs the exact name.

In this example, get pods shows web-pod running. describe pod shows the image, the node and the events. logs shows the web server start lines. The three commands together answer what the Pod is, where it runs and what it is doing.

Note

Events expire after about an hour, so read them while they are fresh.

Try it Yourself

Edit the code, then press Run.

Running is simulated · Rust Playground

Exercise

Which command shows a Pod's image, node and events in one place?