Skip to content

Room 12

DEPLOYMENTS


The Time Machine

  • Deployments give you the power to travel through versions. Roll forward, roll back - control your releases.
  • A deployment has been updated with a broken image. Roll it back to reveal the password.

📜 Mission Briefing

  1. Apply deployment-v1.yaml - creates a deployment with nginx:1.24 (3 replicas).
  2. Check the rollout status: kubectl rollout status deployment/time-machine.
  3. Update the image to a broken version: kubectl set image deployment/time-machine app=nginx:broken.
  4. Watch the rollout fail - pods will be in ImagePullBackOff.
  5. Roll back: kubectl rollout undo deployment/time-machine.
  6. Once healthy, exec into any pod and read /usr/share/nginx/html/password.txt.

Key Commands
Command Purpose
kubectl create deployment NAME --image=IMG Create deployment
kubectl set image deployment/NAME CONTAINER=IMAGE Update image
kubectl rollout status deployment/NAME Check rollout progress
kubectl rollout history deployment/NAME View revisions
kubectl rollout undo deployment/NAME Rollback to previous
kubectl rollout undo deployment/NAME --to-revision=N Rollback to specific
kubectl scale deployment NAME --replicas=N Scale replicas

How Deployments Work
apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-deployment
spec:
  replicas: 3
  strategy:
    type: RollingUpdate        # or Recreate
    rollingUpdate:
      maxSurge: 1              # Extra pods during update
      maxUnavailable: 0        # Pods unavailable during update
  selector:
    matchLabels:
      app: my-app
  template:
    metadata:
      labels:
        app: my-app
    spec:
      containers:
        - name: app
          image: nginx:1.24
          ports:
            - containerPort: 80
# Deployment lifecycle
kubectl create deployment my-app --image=nginx:1.24 --replicas=3

# Update strategies:
# RollingUpdate: Gradually replace old pods (zero-downtime)
# Recreate: Kill all old pods, then create new ones

# Perform a rolling update
kubectl set image deployment/my-app app=nginx:1.25

# Watch the rollout
kubectl rollout status deployment/my-app

# View rollout history
kubectl rollout history deployment/my-app
kubectl rollout history deployment/my-app --revision=2

# Rollback
kubectl rollout undo deployment/my-app
kubectl rollout undo deployment/my-app --to-revision=1

# Pause/resume rollouts
kubectl rollout pause deployment/my-app
kubectl rollout resume deployment/my-app

# Record changes (add --record flag, deprecated but still works)
kubectl set image deployment/my-app app=nginx:1.25

Hints

Hint 1

After the broken update, check status:

kubectl rollout status deployment/time-machine
kubectl get pods -l app=time-machine

Hint 2

Rollback to the working version:

kubectl rollout undo deployment/time-machine

Hint 3

Read the password:

kubectl exec deploy/time-machine -- cat /usr/share/nginx/html/password.txt
The password is rollout42.


🔓 Unlock Room 13

openssl enc -aes-256-cbc -d -a -pbkdf2 \
        -in ../room_13/README             \
        -out ../room_13/README.txt        \
        -pass pass:PASSWORD
cat ../room_13/README.txt