advanced

Deployment

Manage replicated stateless pods with rollout history, rolling updates, rollback, and desired-state reconciliation.

A Deployment manages desired replica count, ReplicaSets, rolling updates, rollback history, and reconciliation for stateless workloads such as web APIs and SSR apps.

					apiVersion: apps/v1
kind: Deployment
metadata:
  name: api
spec:
  replicas: 3
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 0
      maxSurge: 1
  selector:
    matchLabels:
      app: api
  template:
    metadata:
      labels:
        app: api
    spec:
      containers:
        - name: api
          image: my-api:1.2.0
          readinessProbe:
            httpGet:
              path: /health/ready
              port: 3000
				

Rollouts should be gated with readiness probes so traffic does not hit instances that cannot serve.

On interviews: `maxUnavailable`, `maxSurge`, image pull policy, labels/selectors, rollout failure detection, and rollback.

Common pitfalls: changing selectors orphans pods; rolling out without readiness routes traffic too early.

The trade-off is rollout speed versus safety during partial failures.

Checklist:

  • Stable labels and selectors.
  • Configure rollout strategy explicitly.
  • Gate traffic with readiness probes.
  • Keep rollout history for rollback.