Kubernetes Pods
What is a Pod?
A Pod is the smallest deployable unit in Kubernetes. It represents a single instance of a running process in your cluster. A Pod encapsulates one or more containers (such as Docker containers), storage resources, a unique network IP, and options that govern how the containers should run.
Think of a Pod as a "logical host" for your application container. While most Pods contain a single container, some designs use multiple containers that need to share resources tightly — for example, a web server container paired with a sidecar that collects logs.
Container Specification
Each container in a Pod is defined with a specification that includes:
- image — The container image to run (e.g.,
nginx:latest) - ports — Network ports the container exposes
- env — Environment variables to set inside the container
- resources — CPU and memory limits/requests
- volumeMounts — Paths where volumes are mounted into the container
Pod Manifest Example
Here is a basic Pod manifest in YAML:
apiVersion: v1
kind: Pod
metadata:
name: my-first-pod
labels:
app: my-app
spec:
containers:
- name: web
image: nginx:1.25
ports:
- containerPort: 80
Key fields to understand:
apiVersion: v1— The Kubernetes API version for this resource.kind: Pod— The type of resource being created.metadata.name— A unique name for the Pod within its namespace.spec.containers— A list of containers that run inside the Pod.containers[].image— The container image to pull and run.containers[].ports— Ports the container listens on.
Exercise: Complete the Pod Manifest
The following Pod manifest is missing the image field for the container. Fill in the correct field name and value to run an nginx:1.25 container.