Skip to content
StackDecode
BeginnerLesson 6 of 35

Deployments and ReplicaSets

Declare how many copies to run and let Kubernetes maintain them.

A Deployment manages a ReplicaSet, which manages the pods. You edit the Deployment; it handles updates.

yaml
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
bash
kubectl apply -f deploy.yaml
kubectl scale deployment web --replicas=5
kubectl get deploy,rs,pods

Delete a pod and watch the ReplicaSet create a replacement: that is self-healing.