Pod
A Pod is the smallest deployable unit in Kubernetes: one or more containers that share a network identity, storage volumes, and lifecycle. Every container runs inside a pod, and every pod gets its own IP address in the cluster.
Why pods exist
Some processes must run together, such as an app and a log shipper. Putting them in one pod gives them the same IP and localhost network, and lets them share volumes. Kubernetes schedules, scales, and restarts the pod as one unit.
Pod lifecycle phases
| Phase | Meaning |
|---|---|
| Pending | Accepted, waiting for scheduling or image pull |
| Running | Bound to a node, at least one container running |
| Succeeded | All containers exited with 0 |
| Failed | A container exited non-zero and will not restart |
| Unknown | Node contact lost |
A pod spec
apiVersion: v1kind: Podmetadata: name: payment-api namespace: production labels: app: payment-apispec: containers: - name: payment-api image: registry.example.com/payment-api:v3.1.0 ports: - containerPort: 8080 env: - name: DB_PASSWORD valueFrom: secretKeyRef: name: db-credentials key: password resources: requests: { cpu: "250m", memory: "256Mi" } limits: { memory: "512Mi" } readinessProbe: httpGet: { path: /health, port: 8080 } restartPolicy: Always automountServiceAccountToken: falseMulti-container patterns
- Sidecar: extends the main container, for example log shipping or a mesh proxy.
- Init container: runs to completion before the app starts, for migrations or waiting on dependencies.
Inspect
kubectl get pods -n production -o widekubectl describe pod payment-api -n productionkubectl logs payment-api -n production --previouskubectl exec -it payment-api -n production -- sh| Status | First step |
|---|---|
| Pending | describe pod, read Events |
| ImagePullBackOff | Check image and credentials |
| CrashLoopBackOff | logs --previous |
| Evicted | describe node for pressure |
RememberA pod with an IP is not necessarily ready. Traffic flows only once the readiness probe passes.
SecurityPods get a ServiceAccount token by default. If the app does not call the Kubernetes API, set
automountServiceAccountToken: false.
Common MistakeCreating bare pods in production. If the node dies, the pod is gone. Use a Deployment, StatefulSet, or Job.
Frequently Asked Questions
Why does Kubernetes use pods instead of scheduling containers directly?
Tightly coupled containers need to share networking and storage and be scheduled and restarted together. The pod is the atomic scheduling unit even when it holds a single container.
Can I rely on a pod's IP address?
No. It changes whenever the pod is recreated. Address pods through a Service, which provides a stable virtual IP and DNS name.
What is the difference between init containers and sidecars?
Init containers run to completion before the main containers start. Sidecars run alongside the main containers for the pod's lifetime.