Workload health and shutdown
Probe the right failure mode
Startup probes allow slow initialization; readiness determines whether the workload should receive normal Service traffic; liveness detects a condition that may benefit from restarting the container. Failed startup or liveness probes can trigger restarts after their failure threshold. Failed readiness alone does not restart the container. Our static /healthz checks whether Nginx responds, not whether a separate API or database is healthy. For a real proxy, design readiness around meaningful service ability, and avoid restarting every proxy merely because an upstream is temporarily unavailable.
startupProbe: httpGet: path: /healthz port: http periodSeconds: 5 timeoutSeconds: 2 failureThreshold: 12readinessProbe: httpGet: path: /healthz port: http periodSeconds: 5 timeoutSeconds: 2 failureThreshold: 2livenessProbe: httpGet: path: /healthz port: http periodSeconds: 5 timeoutSeconds: 2 failureThreshold: 3Budget graceful shutdown
Kubernetes initiates termination and updates endpoint conditions; endpoint removal and traffic draining are asynchronous. Nginx handles QUIT as graceful shutdown and TERM as fast shutdown. Verify the selected image stop signal and runtime behavior; do not assume Kubernetes sends QUIT to every image. The lab uses a foreground master and 30 seconds of Pod grace, with a 10-second worker shutdown timeout. Select an image verified to request SIGQUIT on stop, or adapt and test a reviewed graceful-stop strategy. If you add preStop, its duration consumes the Pod grace period. Persistent streams may still be interrupted.
worker_shutdown_timeout 10s;pid /tmp/nginx.pid;Make the rollout observable
With two replicas, maxUnavailable 0 and maxSurge 1, the controller aims to keep the desired count available while creating an extra Pod. Resource quotas, scheduling, failed probes and terminating Pods can affect the actual count. A successful rollout proves controller progress, not the correctness of every route. Compare expected status/body, check events and application logs, and use bounded requests to observe old/new markers. Do not promise zero downtime merely from these settings.
replicas: 2strategy: type: RollingUpdate rollingUpdate: maxUnavailable: 0 maxSurge: 1Rollback the complete change
The manifest lab retains both config versions and the selected digest. If v2 returns an incorrect marker or cannot become ready, stop the rollout workflow, capture nonsensitive events and restore the known-good rendered v1 manifest. Check that the Deployment becomes available, then verify the HTTP result again. A rollout status timeout is evidence of incomplete progress, not an automatic rollback. Use the existing lab namespace only and remove just its owned resources after the exercise.
kubectl --context "$LAB_CONTEXT" -n bm-nginx49 rollout status deployment/catalog --timeout=180s# If a reviewed rollback is required:kubectl --context "$LAB_CONTEXT" apply -f workload-v1.yamlUse the Chapter 49 manual practice and lab. Configuration and manifest snippets are illustrative. Kubernetes execution and image compatibility have not been verified; no cluster is required for offline study.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Workload health and shutdown
Assess decisions from the lesson and original lab.
What does a failed readiness probe normally do?
What is checked by this lab’s health endpoint?
Which Nginx signal requests graceful shutdown?
What happens to Pod grace time while a preStop hook runs?
What should follow a successful rollout status?