Kubernetes Pods are the smallest deployable units in Kubernetes, representing a single instance of a running process in your cluster. This guide explains what a Pod is, how it works, how to create and manage one, and common troubleshooting steps. You will learn the core concepts, lifecycle, and best practices for using Pods effectively.
What Exactly Is a Pod?
A Pod is a wrapper around one or more containers that share the same network namespace, storage volumes, and lifecycle. The most common pattern is a single container per Pod, but multi-container Pods exist for cases where containers need to share data or communicate via localhost. Each Pod gets a unique IP address within the cluster, and containers inside the Pod can reach each other on 127.0.0.1.
How Pods Differ from Containers
Containers are isolated processes with their own filesystem, but they lack the shared context that Pods provide. In Kubernetes, you almost never run a container directly—you always run it inside a Pod. The Pod adds a layer of abstraction that allows Kubernetes to manage the container’s networking, storage, and restart policy. For example, if you have a web server and a log shipper that needs to read the same log files, you put them in the same Pod so they can share a volume.
Creating a Pod: The YAML Manifest
Every Pod is defined in a YAML file that contains the API version, kind, metadata, and spec. Here is a minimal example:
apiVersion: v1
kind: Pod
metadata:
name: my-nginx
spec:
containers:
- name: nginx
image: nginx:1.25
ports:
- containerPort: 80
You apply it with kubectl apply -f pod.yaml. The image field pulls the container image from a registry. The ports field is informational; it does not automatically expose the port to the outside world. To access the Pod, you need a Service or use kubectl port-forward.
Pod Lifecycle and Phases
A Pod goes through several phases: Pending, Running, Succeeded, Failed, and Unknown. Pending means the Pod has been accepted but not yet scheduled. Running means it has been placed on a node and all containers are running. Succeeded occurs when all containers exit with code 0. Failed happens when at least one container exits with a non-zero code. Unknown usually indicates a communication error with the node.
Containers within a Pod also have states: Waiting, Running, and Terminated. The kubectl describe pod command shows these states and events, which is the first step in debugging.
Common Pod Operations
Here are the most frequent kubectl commands you will use with Pods:
kubectl get pods– list all Pods in the current namespace.kubectl describe pod <name>– show detailed status and events.kubectl logs <pod> -c <container>– fetch logs from a specific container.kubectl exec -it <pod> -- /bin/sh– open a shell inside a container.kubectl delete pod <name>– remove the Pod.
When you delete a Pod that is managed by a Deployment, the Deployment automatically creates a new one. If you delete a standalone Pod, it is gone permanently.
Multi-Container Pods and Sidecars
Multi-container Pods are useful when containers need to share memory or a volume. A common pattern is the sidecar container, which extends or enhances the main container. For example, a sidecar can serve files from a shared volume that the main container writes to, or it can handle TLS termination. Another pattern is the adapter container, which transforms output from the main container to match an external format. The ambassador container proxies network connections to an external service, making the main container think it is talking locally.
Containers in the same Pod start and stop together. They share the same network namespace, so they must avoid port conflicts. They also share the same PID namespace if you enable shareProcessNamespace: true in the Pod spec.
Pod Networking and Storage
Every Pod gets a cluster-wide unique IP address, and containers inside it share that IP. Communication between Pods is handled by the cluster network, which is typically a CNI plugin like Calico or Flannel. For storage, you can attach volumes to a Pod—either ephemeral (emptyDir) or persistent (PersistentVolumeClaim). The volume is mounted into the container’s filesystem at a specified path.
Here is an example of a Pod with a shared emptyDir volume:
spec:
containers:
- name: writer
image: busybox
command: ["/bin/sh", "-c", "echo hello > /data/file; sleep 3600"]
volumeMounts:
- name: shared-data
mountPath: /data
- name: reader
image: busybox
command: ["/bin/sh", "-c", "cat /data/file; sleep 3600"]
volumeMounts:
- name: shared-data
mountPath: /data
volumes:
- name: shared-data
emptyDir: {}
Common Problems and Troubleshooting
When a Pod fails, check the following:
- ImagePullBackOff – Kubernetes cannot pull the image. Check the image name, tag, and registry credentials.
- CrashLoopBackOff – The container starts, exits, and restarts repeatedly. View logs with
kubectl logsto see the error. - Pending – The Pod is not scheduled. Run
kubectl describe podto see why; often it is insufficient CPU/memory or a node selector that matches no node. - ContainerCreating – The container is still being set up. This can be due to a slow image pull or a volume mount failure.
- RunContainerError – The container fails to start due to a missing command, bad entrypoint, or permission issue.
Always start with kubectl describe pod and kubectl logs—they contain the most useful information.
Best Practices for Pod Design
Follow these guidelines to make your Pods reliable and maintainable:
- Use Deployments, ReplicaSets, or StatefulSets instead of bare Pods for production workloads.
- Set resource requests and limits for CPU and memory to avoid noisy neighbors.
- Define liveness and readiness probes so Kubernetes can restart unhealthy containers and route traffic only to ready ones.
- Keep Pods immutable—do not update a Pod in place; recreate it with a new image tag.
- Use labels and annotations for organization and automation.
Frequently Asked Questions
Can a Pod contain multiple containers?
Yes, a Pod can contain multiple containers, but they must share the same network namespace and can share volumes. This is useful for sidecar patterns, but it also means they are scheduled together and scale together.
How do I access a Pod from outside the cluster?
You can use a Service of type NodePort, LoadBalancer, or Ingress. For development, kubectl port-forward is the quickest way to reach a Pod on your local machine.
What is the difference between a Pod and a Deployment?
A Deployment manages a set of identical Pods and handles rolling updates, scaling, and self-healing. A Pod is a single instance. You rarely create a Pod directly; instead, you create a Deployment that creates Pods.
Why is my Pod stuck in Pending?
Pending means the Pod has not been scheduled to a node. Check if the cluster has enough resources, if there are node selectors or taints that prevent scheduling, or if the scheduler is running.
How do I update a Pod’s image?
If the Pod is managed by a Deployment, update the Deployment’s image and it will perform a rolling update. For a bare Pod, you must delete and recreate it with the new image.
What happens if a container inside a Pod crashes?
If the container exits, the kubelet restarts it according to the Pod’s restart policy (Always, OnFailure, or Never). The Pod itself remains Running as long as the container is restarted. If the container keeps crashing, it will enter CrashLoopBackOff.
Related
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.
More cards in this drawer
- Campus Tech Innovation Hubs: What They Are
- Poco C51 Airtel Prepaid Locked Variant India?
- Jenkins vs GitHub Actions: Which CI/CD Fits Your Team?
- Turn Off Backup Encryption in iTunes?
- Shared VPS Hosting: Is It Better?
- Disk Defrag Pro: What It Does and Whether You Need It