Volume 4 · Chapter 7 — Compute and Containers
Kubernetes Configuration, Health, and Safe Updates
7.1 Introduction
Running Pods is only part of operating a service; you also need to supply configuration and secrets, let Kubernetes know whether your app is healthy, and deploy new versions without downtime or a way back. This chapter covers ConfigMaps and Secrets, health probes, and rolling updates and rollbacks - the mechanisms that make a Kubernetes service configurable, self-healing at the application level, and safely deployable. These are heavily represented in production troubleshooting and interviews because they’re where deployments succeed or fail.
7.2 ConfigMaps and Secrets
Applications need configuration, and it should be external to the image so the same image runs in every environment with different settings. A ConfigMap holds non-sensitive configuration - settings, feature flags, environment-specific values - which Pods consume as environment variables or files, so you change configuration without rebuilding the image. A Secret holds sensitive values - passwords, tokens, keys - similarly injected into Pods but handled more carefully. On EKS, the best practice is to back Kubernetes Secrets with a proper secrets store (like Secrets Manager) and give Pods IAM roles to fetch secrets at runtime, rather than baking sensitive data into images or config. The principle is the same as elsewhere: externalize configuration, keep secrets out of images, and inject both at runtime so one image is promotable across environments.
7.3 Health Probes
Kubernetes needs to know whether your application is actually working, which it determines with probes. A liveness probe checks whether the application is still alive; if it fails, Kubernetes restarts the container, recovering from a hung or broken process automatically. A readiness probe checks whether the application is ready to receive traffic; if it fails, Kubernetes stops sending the Pod traffic (removing it from the Service) until it’s ready again, without restarting it. The distinction matters: liveness governs restarts (is it broken?), readiness governs traffic (is it ready right now?). Correct probes are what make self-healing and zero-downtime deployments actually work - a Pod only receives traffic when ready, and a broken Pod is restarted - so misconfigured probes are a leading cause of deployment problems.
flowchart TB
Pod[Pod / container] --> Live{Liveness probe}
Pod --> Ready{Readiness probe}
Live -->|fails| Restart[Kubernetes restarts container]
Live -->|passes| OK1[Keep running]
Ready -->|fails| NoTraffic[Removed from Service - no traffic]
Ready -->|passes| Traffic[Added to Service - receives traffic] 7.4 Rolling Updates and Rollbacks
A Deployment updates an application with a rolling update: it gradually replaces old-version Pods with new-version Pods a few at a time, waiting for each new Pod to become ready (via its readiness probe) before continuing, so the service stays available throughout - there’s never a moment with no healthy Pods. If something goes wrong, a rollback returns to the previous version by rolling back to the prior Pod template, equally gradually. This is how you deploy safely: new version rolled out incrementally with health gating, and a fast, built-in path back if the new version misbehaves. Because images are immutable and versioned, rolling forward and back is just changing which image the Deployment runs, and readiness probes ensure only healthy Pods take traffic during the transition.
7.5 Resource Requests, Limits, and Autoscaling
To schedule and scale well, Pods declare resource requests (the CPU and memory they need, used to place them on nodes with capacity) and limits (the maximum they may consume, preventing one Pod from starving others). Getting these right keeps the cluster stable and well-utilized. On top, Kubernetes can autoscale: horizontal Pod autoscaling adds or removes Pod replicas based on load metrics (the container-level equivalent of Auto Scaling), and cluster autoscaling adds or removes nodes as needed - or Fargate removes node management entirely. Together, resource requests/limits and autoscaling let a Kubernetes platform place workloads efficiently and scale them with demand while protecting Pods from resource contention.
7.6 Banking Production Scenario
A bank externalizes each service’s configuration in ConfigMaps and injects secrets at runtime from Secrets Manager via Pod IAM roles, so one image promotes cleanly from test to production. Every service defines liveness and readiness probes, so broken Pods restart and Pods receive traffic only when ready. Deployments use rolling updates gated by readiness probes, so new versions roll out with zero downtime, and if a release misbehaves the team rolls back to the previous image immediately. Pods declare resource requests and limits for stable scheduling, horizontal Pod autoscaling adds replicas under load, and Fargate removes node management. The combination gives configurable, self-healing services with safe, reversible, zero-downtime deployments - exactly what a bank needs for frequent, low-risk releases.
7.7 Troubleshooting: Config, Probes, and Deployments
This is where many production incidents live. A rolling update that causes errors or downtime usually means the readiness probe is missing or wrong, so Pods receive traffic before they’re ready - the fix is an accurate readiness probe so the rollout gates correctly. Pods restarting in a loop often mean the liveness probe is too aggressive (killing a healthy-but-slow app) or the app is genuinely crashing - tune the probe or fix the app. A new deployment behaving badly should be rolled back immediately to the previous version, then investigated. Configuration or secret problems show as the app failing to start or misbehaving because a ConfigMap/Secret is missing or wrong, or the Pod’s role can’t fetch the secret. Pods evicted or throttled indicate resource limits set too low or requests misjudged. The discipline is correct probes, externalized config and runtime secrets, health-gated rolling updates with a ready rollback, and sensible resource requests/limits.
What's the difference between liveness and readiness probes, and how do they enable safe rolling updates?
Liveness and readiness probes are how Kubernetes knows the state of your application, and they answer two different questions. A liveness probe checks whether the application is still alive and functioning; if it fails, Kubernetes concludes the container is broken or hung and restarts it, which recovers automatically from a stuck process. A readiness probe checks whether the application is ready to receive traffic right now; if it fails, Kubernetes stops sending that Pod traffic - removing it from the Service’s pool - but does not restart it, and resumes sending traffic once it passes again. So the crucial distinction is that liveness governs restarts (is the app broken and needing a restart?) while readiness governs traffic (is the app ready to serve at this moment?). An app might be alive but temporarily not ready - for example still warming up, loading data, or briefly overloaded - and readiness handles that by withholding traffic without the disruption of a restart. These probes are what make rolling updates safe and zero-downtime. A Deployment performs a rolling update by gradually replacing old-version Pods with new-version Pods a few at a time, and critically it waits for each new Pod to pass its readiness probe before sending it traffic and before proceeding to replace more old Pods. Because it only shifts traffic to Pods that report ready and never removes the old ones until new ones are serving, there’s never a moment without healthy Pods handling requests - the service stays available throughout the deployment. If the new version’s Pods never become ready (a bad release), the rollout stalls rather than taking the service down, and you roll back to the previous version, which the Deployment does equally gradually by returning to the prior Pod template. So readiness probes are the gate that ensures only healthy new Pods take traffic during a rollout, liveness probes keep individual Pods self-healing throughout, and together with the Deployment’s incremental replace-and-health-check behaviour they deliver safe, zero-downtime rolling updates with a reliable rollback path. This is exactly why misconfigured probes - especially a missing or wrong readiness probe - are one of the most common causes of deployment errors: without a correct readiness probe, Kubernetes sends traffic to Pods that aren’t actually ready, and the “zero-downtime” rollout causes downtime.
Chapter Revision Notes
- ConfigMaps hold non-sensitive config; Secrets hold sensitive values - externalize both and inject at runtime so one image runs everywhere; back Secrets with Secrets Manager + Pod IAM roles.
- Liveness probe governs restarts (is it broken?); readiness probe governs traffic (is it ready now?).
- Rolling updates replace Pods gradually, gated by readiness probes, for zero downtime; rollbacks return to the previous image.
- Resource requests (for scheduling) and limits (to prevent contention) keep the cluster stable; HPA and cluster autoscaling (or Fargate) scale it.
- Misconfigured probes - especially a missing readiness probe - are a top cause of deployment failures.