Pod Fundamentals
The smallest deployable unit in Kubernetes. Understanding Pods is foundational — everything in K8s (Deployments, ReplicaSets, DaemonSets) ultimately manages Pods.
Source: CKA Day 7 — Pod Explained
What is a Pod?
A Pod is the smallest and simplest unit in the Kubernetes object model. It represents a single instance of a running process in your cluster.
Multi-Container Pods
A Pod can contain one or more containers that share:
- Network namespace (same IP address and port space)
- Storage volumes (shared filesystems)
- Linux namespaces (ipc, uts)
Containers in the same Pod are always co-located and co-scheduled on the same node.
Best practice: Use 1 container per Pod, except for sidecar patterns (logging, proxy, git sync).
Imperative vs Declarative
Imperative (kubectl commands)
Directly manage resources via CLI — fast for experiments, not reproducible.
| Command | Purpose |
|---|---|
kubectl run nginx --image=nginx | Create a Pod |
kubectl get pods | List pods |
kubectl get pods -o wide | List with node/IP details |
kubectl describe pod nginx | Detailed pod info |
kubectl delete pod nginx | Delete a pod |
kubectl exec -it nginx -- /bin/sh | Interactive shell |
kubectl logs nginx | View logs |
Declarative (YAML manifests)
Define desired state in YAML — version controlled, auditable, GitOps-friendly.
apiVersion: v1
kind: Pod
metadata:
name: my-pod
labels:
app: web
spec:
containers:
- name: nginx-container
image: nginx:latest
ports:
- containerPort: 80kubectl apply -f pod.yaml
kubectl delete -f pod.yamlKey YAML Fields
| Field | Description |
|---|---|
apiVersion | API version (v1 for Pod) |
kind | Object type (Pod, Deployment, Service, etc.) |
metadata | Identification data (name, namespace, labels, annotations) |
spec | Desired state specification |
spec.containers | Containers to run in the Pod |
spec.containers[].name | Container name |
spec.containers[].image | Docker image |
spec.containers[].ports | Exposed ports |
Pod Lifecycle
| Phase | Description |
|---|---|
| Pending | Accepted by cluster, containers not yet running |
| Running | Bound to node, at least one container running |
| Succeeded | All containers terminated successfully |
| Failed | All containers terminated, at least one failed |
| Unknown | State cannot be determined |
Pod IP Ephemerality
Every Pod receives a unique internal IP address. However, this IP is not stable — it changes on every restart, reschedule, or replacement.
# Original Pod IP
kubectl describe pod nginx-deploy-abc123 | grep IP
# IP: 10.244.1.2
# Delete and recreate the Pod
kubectl delete pod nginx-deploy-abc123
# New Pod gets a different IP
kubectl describe pod nginx-deploy-def456 | grep IP
# IP: 10.244.2.3This is why Services are critical: they provide a stable virtual IP and DNS name that front a dynamic set of Pod backends. Front-end Pods should talk to back-end Pods via a Service (backend-svc:8080), never by hardcoding Pod IPs. Source: CKA Day 9
Multi-Container Example
apiVersion: v1
kind: Pod
metadata:
name: multi-container-pod
spec:
containers:
- name: nginx
image: nginx
ports:
- containerPort: 80
- name: sidecar
image: busybox
command: ['sh', '-c', 'echo Hello from sidecar && sleep 3600']YAML Tips
- Indentation matters — use spaces, never tabs
- Validate before applying:
kubectl apply --dry-run=client -f file.yaml - Explore fields:
kubectl explain pod.spec
Production Note: You almost never deploy bare Pods in production. Pods are managed by higher-level controllers like Deployments and ReplicaSets, which provide self-healing, scaling, and rolling updates. Source: CKA Day 8
CKA Relevance
The CKA exam heavily tests both imperative speed and declarative reproducibility:
- Create, debug, and modify Pods quickly under time pressure
- Write YAML manifests from memory
- Understand Pod networking and multi-container patterns
- Know that Deployments manage ReplicaSets, which manage Pods
Related Pages
- Kubernetes Services — Stable networking for ephemeral Pods
- Kubernetes Service Types — How to expose Pods externally
- Deployment, ReplicaSet & Replication Controller — The controllers that manage Pod lifecycle
- Kubernetes Namespaces — Scope isolation for Pods and workloads
- Kubernetes Architecture — How kubelet and the scheduler manage Pods
- CKA Certification — Exam structure and domains
Tags: kubernetes pod workload yaml cka devops containers