Kubernetes Pods Basics
Understanding Kubernetes Pods
Kubernetes pods are the smallest deployable units in container orchestration, representing a single instance of a running process in a cluster. Unlike traditional container deployments, pods can encapsulate one or multiple containers that share network and storage resources.
Pod Architecture and Key Characteristics
Pods provide a unique approach to container deployment with several critical features:
Feature |
Description |
Shared Network Namespace |
Containers within a pod share IP address and network interfaces |
Co-location |
Containers can be scheduled on the same node |
Resource Sharing |
Containers can share volumes and communicate locally |
graph TD
A[Pod] --> B[Container 1]
A --> C[Container 2]
B --> D[Network Namespace]
C --> D
Creating a Basic Pod Configuration
Here's an example pod configuration for Ubuntu 22.04:
apiVersion: v1
kind: Pod
metadata:
name: example-pod
spec:
containers:
- name: nginx-container
image: nginx:latest
ports:
- containerPort: 80
Pod Lifecycle Management
Kubernetes manages pod lifecycle through several states:
- Pending: Pod accepted but not yet created
- Running: All containers initialized and running
- Succeeded: All containers completed successfully
- Failed: At least one container has failed
Container Networking in Pods
Containers within a pod communicate via localhost, enabling seamless inter-container communication without complex networking configurations.
Pod Deployment Commands
Basic pod deployment commands on Ubuntu:
## Create pod
kubectl apply -f pod-config.yaml
## List pods
kubectl get pods
## Describe pod details
kubectl describe pod example-pod