Smallest Deployable Unit
A Pod is the smallest deployable object in Kubernetes. Kubernetes schedules and manages Pods rather than individual containers.
Key Topics
- • Pod abstraction
- • Container grouping
- • Scheduling
- • Workloads
Learn what Kubernetes Pods are, how they run containers, how Pod networking and storage work, understand the Pod lifecycle, create Pods using YAML, and manage workloads using Kubernetes.
Kubernetes Architecture
Pods and Containers
Shared Networking
Shared Storage
Pod Lifecycle
Multi-Container Pods
Introduction
A Pod is the smallest deployable unit in Kubernetes. A Pod represents one or more containers that run together as a single unit on a Kubernetes node.
Kubernetes does not normally schedule individual containers directly. Instead, containers are grouped inside Pods, which provide shared networking, shared storage, and a common execution environment.
Most applications use one main container per Pod, but multi-container Pods can also be useful when containers need to work closely together.
Pod Fundamentals
Pods provide the environment where containers run and interact with Kubernetes resources.
A Pod is the smallest deployable object in Kubernetes. Kubernetes schedules and manages Pods rather than individual containers.
Key Topics
Containers inside the same Pod share networking resources and can communicate with each other using localhost.
Key Topics
Containers inside a Pod can share storage by mounting the same Kubernetes Volume.
Key Topics
Pods move through different lifecycle phases depending on their creation, execution, completion, or failure.
Key Topics
Pod Architecture
A Pod can contain containers, networking configuration, storage, application configuration, and resource requirements.
The Kubernetes object that represents one or more containers running together.
The application processes that run inside the Pod.
Containers in the Pod share the same network identity and IP address.
Storage resources that can be mounted and shared by containers.
Environment variables, ConfigMaps, Secrets, and other runtime settings.
CPU and memory requests and limits used to manage workload resources.
YAML Configuration
Kubernetes resources are commonly defined using YAML manifests. The manifest describes the desired state of the Pod.
A basic Pod configuration includes the API version, resource type, metadata, and the specification for the containers that should run inside the Pod.
Basic Pod Example
apiVersion: v1
kind: Pod
metadata:
name: nginx-pod
spec:
containers:
- name: nginx
image: nginx:latest
ports:
- containerPort: 80Deploying Pods
After creating a YAML file, you can submit the configuration to the Kubernetes API using kubectl.
Kubernetes will schedule the Pod to an appropriate node based on available resources, scheduling rules, and other cluster configuration.
Create the Pod
kubectl apply -f pod.yaml kubectl get pods kubectl describe pod nginx-pod
Networking
Each Pod receives its own network identity. Containers inside the same Pod share the same network namespace.
This means containers in the same Pod can communicate with each other using localhost while sharing the same IP address.
Communication between different Pods is handled through the Kubernetes networking model and can be exposed using Services.
Pod
Shared Pod IP Address
Container A
localhost
Container B
localhost
Storage
Containers normally have their own filesystem environments, but Kubernetes Volumes can provide shared storage between containers inside the same Pod.
Volumes can also be used to provide configuration, temporary storage, or persistent application data depending on the workload requirements.
Shared Volume Example
spec:
containers:
- name: app
image: nginx
volumeMounts:
- name: shared-data
mountPath: /data
volumes:
- name: shared-data
emptyDir: {}Multi-Container Pods
A Pod can run multiple containers when those containers are tightly coupled and need to share networking or storage.
A common example is a main application container combined with a helper container that performs logging, monitoring, proxying, or other supporting tasks.
Containers that have independent lifecycles are often better deployed as separate Pods and connected through Kubernetes networking.
Multi-Container Pod Example
apiVersion: v1
kind: Pod
metadata:
name: multi-container-pod
spec:
containers:
- name: application
image: nginx
- name: helper
image: busybox
command:
- sh
- -c
- "while true; do sleep 30; done"Pod Lifecycle
Kubernetes tracks the overall state of a Pod using lifecycle phases.
The Pod has been accepted by Kubernetes, but one or more containers have not yet started.
The Pod has been scheduled and at least one container is running or starting.
All containers have completed successfully and will not be restarted.
One or more containers terminated unsuccessfully.
Kubernetes cannot determine the current state of the Pod.
Workload Management
Individual Pods are useful for learning and testing, but production applications are normally managed using Kubernetes workload controllers.
Controllers such as Deployments help maintain the desired number of Pod replicas and can create replacement Pods when existing Pods fail or are terminated.
This allows Kubernetes to manage application availability and updates more effectively than manually creating individual Pods.
Deployment
Manages ReplicaSets and application updates.
ReplicaSet
Helps maintain the desired number of Pod replicas.
Pods
Run the application containers.
kubectl
Use these kubectl commands to create, inspect, troubleshoot, and manage Pods.
kubectl get podsList Pods in the current namespace.
kubectl get pods -o wideList Pods with additional details such as node and IP address.
kubectl describe pod <pod-name>Display detailed information about a Pod.
kubectl logs <pod-name>View logs from a container in a Pod.
kubectl exec -it <pod-name> -- shOpen an interactive shell inside a container.
kubectl delete pod <pod-name>Delete a Pod from the cluster.
kubectl apply -f pod.yamlCreate or update a Pod using a YAML manifest.
kubectl get pods --watchContinuously watch changes to Pod status.
Learning Roadmap
Follow these steps to understand how Pods work and how they fit into the Kubernetes ecosystem.
Learn why Kubernetes uses Pods as the smallest deployable unit instead of managing individual containers directly.
Create a simple Pod using a YAML manifest and deploy it to a Kubernetes cluster.
Use kubectl commands to check Pod status, events, networking, and container information.
Understand how containers inside the same Pod share an IP address and communicate using localhost.
Learn when multiple tightly coupled containers can run together inside the same Pod.
Learn why Deployments and other workload controllers are normally used to manage Pods in production.
Best Practices
Use Deployments and other workload controllers instead of manually managing individual Pods for most production workloads.
Specify appropriate CPU and memory requests to help Kubernetes schedule workloads effectively.
Use resource limits where appropriate to prevent workloads from consuming excessive cluster resources.
Use one primary responsibility per container and use multi-container Pods only when containers are tightly coupled.
Configure readiness and liveness probes to help Kubernetes understand application health.
Run containers with only the permissions and access required for their workloads.
Continue Learning
Learn Kubernetes clusters, nodes, architecture, Pods, Deployments, Services, and kubectl fundamentals.
🌐Learn Kubernetes Services, networking, DNS, traffic routing, and communication between workloads.
📦Explore Pods, Deployments, ReplicaSets, StatefulSets, DaemonSets, and Kubernetes workload management.
Next Step
Practice creating Pods, inspecting their status, checking logs, understanding networking, and deploying workloads using Kubernetes controllers.