Skip to content

Kubernetes Pods

A Pod is the smallest deployable unit in Kubernetes. It wraps one or more containers that share a network namespace and storage volumes.

A Pod is not a container — it is a wrapper around one or more containers. Containers in the same pod:

  • Share the same IP address and port space
  • Can communicate via localhost
  • Share mounted volumes

Most pods run a single container. Multi-container pods are used for sidecar patterns (e.g., a log shipper alongside the main app).

apiVersion: v1
kind: Pod
metadata:
name: my-app
labels:
app: my-app
spec:
containers:
- name: my-app
image: nginx:1.25
ports:
- containerPort: 80

Apply it:

Terminal window
kubectl apply -f pod.yaml
PhaseMeaning
PendingAccepted but not yet scheduled or image not yet pulled
RunningAt least one container is running
SucceededAll containers exited with code 0
FailedAt least one container exited with non-zero code
UnknownNode communication lost

Always set these to help the scheduler and protect other workloads:

resources:
requests:
memory: "64Mi"
cpu: "250m"
limits:
memory: "128Mi"
cpu: "500m"
  • requests — minimum guaranteed resources
  • limits — maximum allowed before throttling (CPU) or OOM kill (memory)
Terminal window
# List pods in current namespace
kubectl get pods
# Detailed pod info (events, conditions, IP)
kubectl describe pod my-app
# View logs
kubectl logs my-app
kubectl logs my-app --previous # logs from last crashed container
# Open a shell inside the container
kubectl exec -it my-app -- /bin/sh
# Delete a pod
kubectl delete pod my-app
# Watch pod status changes live
kubectl get pods -w
livenessProbe:
httpGet:
path: /health
port: 8080
initialDelaySeconds: 10
periodSeconds: 5
readinessProbe:
httpGet:
path: /ready
port: 8080
initialDelaySeconds: 5
periodSeconds: 3
  • liveness — restart the container if this fails
  • readiness — remove the pod from service endpoints until this passes

Never rely on a pod’s IP address or local file system. Pods can be rescheduled to different nodes at any time. Use:

  • Services for stable network access
  • PersistentVolumes for durable storage
  • Deployments to manage pod lifecycle (not raw pods)

In practice, you almost never create bare pods — you create Deployments, which manage pods for you.