Pods Basics
This page is a hands-on introduction to Pods: creating them, inspecting them, and running multi-container Pods when they are justified. Every example uses kubectl against a cluster where containerd runs the containers.
Search across all documentation pages
This page is a hands-on introduction to Pods: creating them, inspecting them, and running multi-container Pods when they are justified. Every example uses kubectl against a cluster where containerd runs the containers.
Quick check that your client and cluster are healthy:
kubectl version
kubectl get nodesThe fastest way to get a Pod running for a quick test.
kubectl run web --image=nginx:1.27 --port=80web.--image pins the image; prefer a specific tag over latest.kubectl delete pod web.Declarative manifests are reviewable, versionable, and repeatable.
apiVersion: v1
kind: Pod
metadata:
name: web
labels:
app: web
spec:
containers:
- name: nginx
image: nginx:1.27
ports:
- containerPort: 80apiVersion: v1 and kind: Pod identify the object.labels let Services and controllers select this Pod later.containerPort documents the port; it does not open firewall rules.kubectl apply -f web.yaml.Reading Pod state is the core debugging skill.
kubectl get pod web -o wide
kubectl describe pod webget -o wide shows node placement, Pod IP, and readiness.describe shows events, container states, and restart counts.Logs are the first place to look when a container misbehaves.
kubectl logs web
kubectl logs web --previouslogs shows the current container instance's stdout/stderr.--previous shows the last terminated instance after a crash.-f to follow logs live.-c <container>.Interactive access helps confirm config and connectivity from inside.
kubectl exec -it web -- sh-it attaches an interactive terminal.-- runs inside the container.Containers often need config through env vars and an explicit entrypoint.
apiVersion: v1
kind: Pod
metadata:
name: printer
spec:
restartPolicy: Never
containers:
- name: app
image: busybox:1.36
command: ["sh", "-c"]
args: ["echo Hello $GREETING; sleep 3600"]
env:
- name: GREETING
value: "world"command overrides the image ENTRYPOINT; args overrides CMD.env injects variables the process can read.restartPolicy: Never suits one-shot tasks.$GREETING expansion happens in the shell, not in Kubernetes.Labels are the glue between Pods and the controllers and Services that manage them.
kubectl get pods --show-labels
kubectl label pod web tier=frontend
kubectl get pods -l tier=frontend--show-labels lists all labels on each Pod.label adds or updates a label on the fly.-l filters Pods by a label selector.Use a second container only when it must share the Pod's network or storage.
apiVersion: v1
kind: Pod
metadata:
name: web-logs
spec:
volumes:
- name: logs
emptyDir: {}
containers:
- name: app
image: nginx:1.27
volumeMounts:
- name: logs
mountPath: /var/log/nginx
- name: log-tailer
image: busybox:1.36
command: ["sh", "-c", "tail -F /var/log/nginx/access.log"]
volumeMounts:
- name: logs
mountPath: /var/log/nginxemptyDir volume is shared by both containers for the Pod's lifetime.kubectl logs web-logs -c log-tailer.Production Pods declare what they need and how health is measured.
apiVersion: v1
kind: Pod
metadata:
name: api
spec:
containers:
- name: api
image: registry.example.com/api:1.4.0
ports:
- containerPort: 8080
resources:
requests:
cpu: "100m"
memory: "128Mi"
limits:
memory: "256Mi"
readinessProbe:
httpGet:
path: /healthz
port: 8080
initialDelaySeconds: 3
periodSeconds: 5requests drive scheduling; limits cap usage (memory over limit is OOM-killed).readinessProbe gates traffic until /healthz returns 200.You rarely run bare Pods in production; a Deployment manages replicas and rollouts.
apiVersion: apps/v1
kind: Deployment
metadata:
name: web
spec:
replicas: 3
selector:
matchLabels:
app: web
template:
metadata:
labels:
app: web
spec:
containers:
- name: nginx
image: nginx:1.27
ports:
- containerPort: 80template is a Pod spec; the Deployment creates and heals Pods from it.replicas: 3 keeps three Pods running and reschedules failures.selector must match the template labels.kubectl apply and watch kubectl rollout status deployment/web.Stack versions: This page was written for Kubernetes 1.36.2, Docker Engine 29.6.1 (BuildKit default), containerd (CRI runtime on nodes), Helm 3, Compose v2, Argo CD (latest - verify at build), and Gateway API (GA - verify controller support at build).
Reviewed by Chris St. John·Last updated Jul 16, 2026