Typorithm · medium

Deployment

deployment-manifestkubernetesdeploymentreplicasselector
Saved on this device
Full lesson · 8 learning steps Open any exercise for focused practice
1

Step 1 of 8 · intro card

Learn Deployment

0%

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.

01

apiVersion: apps/v1, kind: Deployment.

02

spec.replicas sets the desired Pod count.

03

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.27

Read the implementation

Connect each part of the code to the concept before you type.

1. apps/v1 group

Deployments live in the apps/v1 API group, not core v1.

apiVersion: apps/v1

2. Replica count

replicas sets how many identical Pods the Deployment keeps running.

replicas: 3

3. Pod selector

selector.matchLabels tells the Deployment which Pods it owns.

selector:
    matchLabels:
      app: web

4. Template labels

template.metadata.labels stamp every Pod the Deployment creates; they must match the selector.

labels:
        app: web

5. Pod template spec

template.spec is a full Pod spec the Deployment uses as the blueprint.

- name: web
          image: nginx:1.27

A complete learning loop

01

Understand

Read the concept map and follow the code breakdown.

02

Reconstruct

Type the implementation, repair mistakes and work through every recall exercise.

03

Verify

Use the final check without hints; revisit weak concepts in short practice sessions.

Deployment: Lesson & Practice · Typorithm | ApplyDjinn