Workloads, Probes and Autoscaling

Run applications with Deployments, StatefulSets, DaemonSets and Jobs, keep them healthy with probes, and scale them automatically.

Intermediate · about 10 hours · difficulty 3/5

Learn first: Kubernetes Architecture and kubectl

Pods are the unit of scheduling, but you almost never create them directly. Higher-level workload controllers manage pods for you.

Controllers

  • Deployment (via ReplicaSets): stateless apps with rolling updates and kubectl rollout undo. Tune maxSurge and maxUnavailable.
  • StatefulSet: stable names and per-pod storage for databases and queues.
  • DaemonSet: one pod per node (log shippers, node agents).
  • Job and CronJob: run-to-completion and scheduled work.

Keeping pods healthy

  • Resource requests (used for scheduling) and limits (enforced). Without requests the scheduler is guessing; memory over the limit means an OOM kill.
  • Probes: readinessProbe controls whether a pod receives traffic, livenessProbe restarts a stuck container, startupProbe protects slow starters.
  • Graceful shutdown: handle SIGTERM, set terminationGracePeriodSeconds, and a small preStop sleep to let endpoints update.
  • PodDisruptionBudgets keep capacity during node drains.

Scaling

The Horizontal Pod Autoscaler scales replicas on CPU, memory or custom metrics; the Cluster Autoscaler or Karpenter adds nodes; KEDA scales on events such as queue length.

Pitfalls

Liveness probes that check dependencies (a database blip restarts every pod), no requests set, and CrashLoopBackOff debugging without kubectl logs --previous.

Good enough to move on: you can deploy an app with requests, limits, three probes, a PDB and an HPA, and do a rolling update and rollback with zero failed requests.

Key concepts

  • Pods and ReplicaSets
  • Deployments and rolling updates
  • StatefulSets and DaemonSets
  • Jobs and CronJobs
  • Requests and limits
  • Readiness, liveness, startup probes
  • PodDisruptionBudgets
  • HPA and cluster autoscaling
  • KEDA event-driven scaling

Mini project

Deploy an app with 3 replicas, probes, requests/limits and an HPA; run a load test to trigger scaling, then roll out a new version while a script hammers it and confirm zero errors.

Check yourself

What is the difference in behaviour between a failing readiness probe and a failing liveness probe?

Free resources