Summary - Deployment
- Docker & Kubernetes course
- Intermediate
- Lesson 30/82
- 5 min
Combine YAML, replicas and rollout to manage a Deployment.
Summary: Deployment
In this group:
- The Deployment → ReplicaSet → Pod chain; a new ReplicaSet opens when the template changes.
- YAML:
apps/v1,replicas,selector.matchLabels(must match the template label),template;resourcesrequests/limits. - Scaling: declarative (
replicas+ apply) orkubectl scale;rollout statuswaits. - Rolling update:
maxSurge/maxUnavailable;set imageand the change-cause annotation. rollout history/undo/pause/resume/restarthandle version management.
kubectl apply -f web.yaml
kubectl rollout status deploy/web
kubectl rollout undo deploy/webPractice A deployment with a safe strategy
Write a Deployment YAML: name web, replicas: 4; under strategy, type: RollingUpdate, maxSurge: 1, maxUnavailable: 0; selector and template label app: web; container named nginx, image nginx:1.27.
Starter code
# buraya yazSample solution
apiVersion: apps/v1
kind: Deployment
metadata:
name: web
spec:
replicas: 4
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
selector:
matchLabels:
app: web
template:
metadata:
labels:
app: web
spec:
containers:
- name: nginx
image: nginx:1.27Expected output
deployment.apps/web created
Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 With replicas: 4, maxSurge: 1, maxUnavailable: 0, at most how many pods can run at once during an update?
- 8
- 3
- 5 Correct answer
- 4
Explanation: 4 + maxSurge 1 = 5; it never drops below 4.
2 Specify the update strategy.
spec:
strategy:
type: ____
spec:
strategy:
type: RollingUpdate
Explanation: The other built-in strategy is Recreate (closes all first).
3 Match.
| Term | Meaning |
|---|---|
RollingUpdate |
Gradual |
Recreate |
Close all first |
revisionHistoryLimit |
Kept ReplicaSet count |
OOMKilled |
Memory limit exceeded |