Kubernetes Curriculum
What Is A Deployment
A Deployment is the standard Kubernetes object for running stateless application replicas. It manages a fleet of identical Pods and ensures the desired number of replicas is always running — even if nodes fail, Pods crash, or you update the application image.
Deployments are the most-used workload object in Kubernetes. Your web servers, REST APIs, gRPC services, background workers, and microservices all run as Deployments.
The Problem Deployments Solve
Without Deployments, you would create Pods manually:
This creates one Pod. Problems:
- If the Pod crashes, nobody recreates it
- You cannot easily scale to 5 Pods without 5 separate commands
- Updating the image means deleting the old Pod and creating a new one — downtime
- No rollback if the new version is broken
Deployments solve all of these:
The Relationship: Deployment → ReplicaSet → Pods
A Deployment does not directly manage Pods. It creates and manages ReplicaSets, which in turn manage Pods:
When you update the image, the Deployment creates a new ReplicaSet (v3) and gradually shifts replicas from the old ReplicaSet to the new one. Old ReplicaSets are kept (scaled to 0) for rollback.
Anatomy of a Deployment
The selector Field — Critical and Immutable
The spec.selector is the most important field to get right. It defines which Pods belong to this Deployment. Once set, it cannot be changed.
If the selector and template labels do not match, the Deployment creates Pods but cannot find them — they appear as unmanaged orphans.
Deployment Conditions and Status
Deployment Use Cases — When to Use a Deployment
Deployments are for stateless workloads — applications where any replica can serve any request and Pods have no individual identity.
Summary
- Deployments are the standard workload for stateless application replicas — they ensure the desired number of Pods is always running
- Deployments manage ReplicaSets which manage Pods — old ReplicaSets are retained for rollback
- The
selector.matchLabelsmust exactly matchtemplate.metadata.labels— this link is immutable once set replicas,strategy, andrevisionHistoryLimitare the three key configuration fields beyond the Pod template- Use Deployments for stateless services (APIs, web servers, workers); use StatefulSets for databases, DaemonSets for node agents, Jobs for batch tasks
In the next file, 02-creating-deployments.md, you will learn how to create, inspect, and manage Deployments — with production-grade patterns for health checks, affinity, and resource management.