Pods Basics & Multi-Container Patterns
A Pod is the smallest, basic deployable execution unit in Kubernetes. A Pod encapsulates one or more containers that share network IP addresses and storage volumes.
1. Pod Lifecycle States
| Phase | State Description |
|---|---|
Pending | Pod accepted by API Server, but containers are still downloading images or waiting to be scheduled. |
Running | Pod bound to a Worker Node and at least one container is currently running or starting. |
Succeeded | All containers in the Pod completed execution successfully and exited (common in Jobs). |
Failed | At least one container in the Pod terminated in failure (exited with non-zero status). |
2. Multi-Container Pod Patterns (Sidecar Pattern)
In a Sidecar Pattern, an auxiliary helper container runs alongside the main application container within the same Pod to handle secondary tasks like log shipping or proxying:
apiVersion: v1
kind: Pod
metadata:
name: web-app-with-sidecar
spec:
containers:
# Main Web App Container
- name: web-app
image: nginx:alpine
ports:
- containerPort: 80
# Sidecar Container (Log Shipper / Monitoring Helper)
- name: log-shipper
image: fluentd:latest
volumeMounts:
- name: varlog
mountPath: /var/log/nginx
volumes:
- name: varlog
emptyDir: {}Next Up
Learn how to write Kubernetes YAML specs: apiVersion, kind, metadata, spec, labels, and selectors.
Next Lesson: Writing Kubernetes YAML →