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.

CommandPurpose
kubectl run nginx --image=nginxCreate a Pod
kubectl get podsList pods
kubectl get pods -o wideList with node/IP details
kubectl describe pod nginxDetailed pod info
kubectl delete pod nginxDelete a pod
kubectl exec -it nginx -- /bin/shInteractive shell
kubectl logs nginxView 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: 80
kubectl apply -f pod.yaml
kubectl delete -f pod.yaml

Key YAML Fields

FieldDescription
apiVersionAPI version (v1 for Pod)
kindObject type (Pod, Deployment, Service, etc.)
metadataIdentification data (name, namespace, labels, annotations)
specDesired state specification
spec.containersContainers to run in the Pod
spec.containers[].nameContainer name
spec.containers[].imageDocker image
spec.containers[].portsExposed ports

Pod Lifecycle

PhaseDescription
PendingAccepted by cluster, containers not yet running
RunningBound to node, at least one container running
SucceededAll containers terminated successfully
FailedAll containers terminated, at least one failed
UnknownState 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.3

This 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

Tags: kubernetes pod workload yaml cka devops containers