1. apps/v1 group
Deployments live in the apps/v1 API group, not core v1.
apiVersion: apps/v1Typorithm · medium
Step 1 of 8 · intro card
Workloads
A Deployment keeps a set of replica Pods running. spec.selector.matchLabels must exactly match the labels in spec.template.metadata.labels, or the API rejects it.
A Deployment is the standard controller for stateless workloads: it manages a ReplicaSet that keeps spec.replicas Pods alive.
spec.template is a complete Pod template — the blueprint stamped out for each replica, including its own metadata.labels.
The critical contract: spec.selector.matchLabels must match the labels in spec.template.metadata.labels, otherwise the Deployment cannot adopt the Pods it creates and the API server rejects the object.
apiVersion: apps/v1, kind: Deployment.
spec.replicas sets the desired Pod count.
selector.matchLabels must equal template labels.
apiVersion: apps/v1
kind: Deployment
metadata:
name: web
spec:
replicas: 3
selector:
matchLabels:
app: web
template:
metadata:
labels:
app: web
spec:
containers:
- name: web
image: nginx:1.27Connect each part of the code to the concept before you type.
Deployments live in the apps/v1 API group, not core v1.
apiVersion: apps/v1replicas sets how many identical Pods the Deployment keeps running.
replicas: 3selector.matchLabels tells the Deployment which Pods it owns.
selector:
matchLabels:
app: webtemplate.metadata.labels stamp every Pod the Deployment creates; they must match the selector.
labels:
app: webtemplate.spec is a full Pod spec the Deployment uses as the blueprint.
- name: web
image: nginx:1.27Read the concept map and follow the code breakdown.
Type the implementation, repair mistakes and work through every recall exercise.
Use the final check without hints; revisit weak concepts in short practice sessions.