Kubernetes·Kubernetes from first pod to production app

Deployments

Manage replicas and rolling updates with a Deployment.

Intermediate 14 min read Lesson 3 of 300 Challenge included
What you will be able to do
  • Use a Deployment, not a bare pod.
  • Set replicas for availability.
  • Use rolling updates with readiness probes.
  • Roll back with kubectl rollout undo.

In plain English

A Deployment owns ReplicaSets and pods. It keeps the desired replica count, performs rolling updates and supports rollback. Change the image or template to trigger a rollout.

deployment.yamlYAML
apiVersion: apps/v1
kind: Deployment
metadata:
  name: web
spec:
  replicas: 2
  selector:
    matchLabels:
      app: web
  template:
    metadata:
      labels:
        app: web
    spec:
      containers:
        - name: web
          image: nginx:1.27-alpine
          ports:
            - containerPort: 80
Your turn

Scale a deployment

Easy

Write the command that scales a deployment named web to 3 replicas.

BASH · starter
kubectl scale
Check your understanding before moving on.
Knowledge checkQuestion 1

Which object performs rolling updates and keeps replicas running?

Select an answer to continue
Study tools

Make it yours.

Keep a private note for this lesson, then turn the key ideas into flashcards you can revisit.

Sign in to save notes and flashcards.Both are private to your account and stay with your progress.
Sign in
Finished reading?

Lock in what you just learned.

Mark this lesson complete to save your place and move one step closer to the certificate.

Next: Services
Lesson 3 of 300 · 0% of course