Pods, ReplicaSets and Deployments explained
A Pod runs one or more containers together, a ReplicaSet keeps a fixed number of identical Pods alive, and a Deployment manages ReplicaSets so you can update and roll back safely.
Drafted with AI from official documentation. Scripts were run in a test environment and repository links verified. Awaiting a human check. Did it work for you? Last edited Outdated?
Kubernetes never runs a bare container. The smallest thing it schedules is a Pod, and in practice you almost never create Pods by hand either. You create a Deployment, which creates a ReplicaSet, which creates the Pods. Each layer adds one job.
Pod: containers that live together
A Pod is one or more containers that always run on the same node, share one IP address and can share volumes. Most Pods have a single application container; extra containers are used for tightly coupled helpers such as a log shipper or a proxy.
Pods are disposable. When a node fails or a Pod is deleted, it is not moved or repaired; a controller creates a new Pod with a new name and usually a new IP address. That is why you reach Pods through a Service instead of by IP.
ReplicaSet: keep N copies running
A ReplicaSet has a Pod template, a label selector and a replica count. Its controller counts the Pods that match the selector and creates or deletes Pods until the count is right. Delete one Pod and a replacement appears within seconds.
Deployment: updates and rollbacks
A Deployment wraps ReplicaSets and adds versioning. When you change the Pod template (for example the image tag), the Deployment creates a new ReplicaSet and gradually scales it up while scaling the old one down. This is a rolling update. By default at most 25% of the desired Pods may be unavailable and at most 25% extra may be created during the change.
Old ReplicaSets are kept (scaled to zero) as revision history, ten by default, controlled by .spec.revisionHistoryLimit. That history is what makes kubectl rollout undo possible.
apiVersion: apps/v1
kind: Deployment
metadata:
name: web
labels:
app: web
spec:
replicas: 3
selector:
matchLabels:
app: web
template:
metadata:
labels:
app: web
spec:
containers:
- name: web
image: nginx:1.27
ports:
- containerPort: 80
The selector.matchLabels must match the labels in template.metadata.labels; that link is how the ReplicaSet knows which Pods belong to it.
kubectl apply -f web.yaml
kubectl get deployment,replicaset,pods -l app=web
kubectl scale deployment/web --replicas=5
kubectl set image deployment/web web=nginx:1.28
kubectl rollout status deployment/web
kubectl rollout history deployment/web
kubectl rollout undo deployment/web
Namespaces
A namespace is a named group of objects inside one cluster. Names must be unique within a namespace but can repeat across namespaces, and access rules (RBAC) and quotas are often set per namespace. A new cluster starts with default, kube-system (cluster components), kube-public and kube-node-lease. The Kubernetes docs recommend not putting production work in default.
kubectl create namespace shop
kubectl apply -f web.yaml -n shop
kubectl get pods -n shop
kubectl config set-context --current --namespace=shop
Other workload types
- StatefulSet: Pods with stable names (
db-0,db-1) and their own persistent volumes, for databases and clustered software. - DaemonSet: exactly one Pod on every (or every matching) node, for log collectors and node agents.
- Job and CronJob: Pods that run to completion, once or on a schedule.
Official documentation
Did this work for you?
No votes yet. Be the first.
If it did not work, the report form below tells the editors what went wrong.
See also
- 0131 Kubernetes architecture: control plane, nodes, kubelet and etcd A Kubernetes cluster is a control plane that stores and decides the desired state, plus worker nodes that run your containers. This… Beginner · Explains an idea · Linux Article Concepts 15 Oct 2026
- 0135 Deploy your first app on Kubernetes A step-by-step tutorial: write a Deployment and a Service in YAML, apply them, reach the app, add health probes, roll out a… Beginner · Step by step · Linux Article Ingress & networking · Workloads & services 15 Oct 2026
- 0136 Persistent storage in Kubernetes: PersistentVolumes, claims and StorageClasses How to give a Pod storage that survives restarts: request it with a PersistentVolumeClaim, let a StorageClass provision it, and mount it.… Intermediate · Step by step · Linux Article Config, secrets & storage · Workloads & services 15 Oct 2026
- 0138 Kubernetes RBAC basics: least-privilege access for a service account RBAC controls who may do what in a cluster with Roles, ClusterRoles and bindings. This guide grants a CI service account deploy… Advanced · Step by step · Linux Article Concepts · Config, secrets & storage 15 Oct 2026
- 0140 kubectl cheat sheet: the commands you use every day A compact reference of everyday kubectl commands: contexts and namespaces, listing and inspecting objects, logs and exec, applying changes, rollouts, scaling and… Beginner · Cheat sheet · Any system Article Concepts · Troubleshooting 15 Oct 2026
- 0144 Fix: Pod stuck in Pending with “0/3 nodes are available: Insufficient cpu” The scheduler cannot find a node with enough unreserved CPU for the pod's request. Compare the request with node allocatable resources, then… Advanced · Fixes an error · Linux Article Troubleshooting · Workloads & services 15 Oct 2026
Repos in the wild
- kubernetes/kubernetes kubernetes/kubernetes The main source repository of Kubernetes: the API server, scheduler, controller manager, kubelet, kube-proxy and kubectl, plus release notes and issue tracking. GitHub
- Falco: runtime security for Linux and Kubernetes falcosecurity/falco Falco watches system calls on Linux hosts and in containers and raises an alert when a process does something a rule flags as suspicious, such as a shell starting inside a container or a sensitive file being read. GitHub
History
Every saved edit is kept. The plot on the sleeve draws one line per edit. Open any edit to see exactly what changed.
- Dominik +3,281 chars