K8s by Example: Pods
| A Pod is the atomic unit of scheduling in Kubernetes. It wraps one or more containers that share network and storage. Containers in a Pod communicate via |
| pod.yaml | |
| Pods use the core | |
| The | |
| The | |
| Declare container ports. | |
| terminal | |
| Pod lifecycle states: | |
| terminal | |
| Common Pending reasons include insufficient CPU/memory, no matching nodes (affinity/taints), or image pull issues. Check Events for details. | |
| terminal | |
| Pods are ephemeral. When a Pod dies, it’s gone forever - new Pods get new IPs and identities. Use these commands to debug running Pods. | |
| terminal | |
| Execute commands inside a running container. Use | |
| terminal | |
| Create a temporary debug Pod. The | |
| multi-container-pod.yaml | |
| Kubernetes creates a “pause” container that holds the network namespace. App containers join this namespace, sharing the same IP and using | |
| Multi-container Pods are for tightly coupled workloads. Common patterns: sidecar (logging, proxies), ambassador (proxy to external services), adapter (transform output). | |
| sidecar-pod.yaml | |
| The sidecar pattern uses a shared volume. The main app writes logs, and the sidecar container ships them. | |
| The sidecar reads from the same volume and forwards logs to your logging infrastructure. | |
|
| |
| pod-resources.yaml | |
| Resource requests and limits control CPU/memory allocation. Without limits, a Pod can consume all node resources. | |
|
| |
| terminal | |
| Pod deployment is atomic - either all containers start successfully, or the Pod fails. View the full Pod spec with | |
| terminal | |
| Every Pod gets a unique cluster-internal IP. Pods can communicate directly with any other Pod using its IP - no NAT required. | |
| terminal | |
| This is the foundation of Kubernetes flat networking model. All Pods can reach each other directly by IP. | |
| terminal | |
| View logs from a previous container instance. Useful when a container has crashed and restarted. | |