Infrastructure
Azure AKS: diagnose container probes before extending timeouts
A production runbook for separating startup, readiness and liveness failures on AKS, preserving capacity and validating a bounded fix.
An AKS rollout advances, then containers restart or remain unready. The API intermittently fails and the team considers multiplying every probe timeout. Yet a readiness failure, a liveness-triggered restart and a startup budget that expires describe different problems. Raising all thresholds can leave a deadlocked process in service without addressing the cause.
Consider an API whose new release starts slowly and depends on a database. Older replicas still serve traffic. The immediate job is to preserve that capacity, identify the failing mechanism and test a correction within a bounded scope.
Contain and preserve evidence
Pause promotion and competing changes through the normal delivery process. Do not delete pods in bulk: preserve healthy old replicas and establish actual available capacity before intervening. Assign an incident owner and capture the UTC window, namespace, revision, image digest, nodes and customer impact. Confirm that the previous revision and its configuration remain deployable.
These commands are read-only. Substitute the names and context, and protect output that may contain sensitive information.
kubectl config current-context
kubectl -n production rollout status deployment/api --timeout=10s
kubectl -n production get pods -l app=api -o wide
kubectl -n production describe pod POD
kubectl -n production logs POD -c api --previous --timestamps
kubectl -n production get endpointslice -l kubernetes.io/service-name=api -o yaml
kubectl -n production get deployment api -o yaml
Previous-container logs are available only when a prior container instance is retained. Correlate events and timestamps with application logs, latency and memory metrics, and configuration changes. Events can expire, so missing events are not proof of a successful probe. Restarts can also follow OOMKilled, a process exit or pod replacement; inspect the last terminated state before attributing them to probes.
Identify the failing probe
| Observation | Hypothesis to investigate | Expected effect |
|---|---|---|
| Startup fails during initialization | Slower startup, incorrect path or port, or stalled initialization | After the failure threshold, the container is restarted according to its policy; readiness and liveness wait for startup success. |
| Readiness fails while the process stays up | Unavailable dependency, slow response or an incorrect check contract | The pod becomes unready and normally stops receiving regular traffic through Services. |
| Liveness fails after startup | Deadlock, an expensive endpoint or a temporarily unavailable dependency | The container is restarted after the failure threshold. |
See the Kubernetes probe documentation for the precise behavior. Inspect the applied manifest for the actual container, port, path, protocol, thresholds and timing. A successful request from another pod does not prove that the kubelet’s path works; compare it with the exact event and cluster network constraints. Inspect EndpointSlice conditions and the actual ingress or load-balancer behavior: an unready pod alone does not prove that every traffic path drains correctly.
In this example, if liveness fails only when the database is slow, restarting every replica can amplify the incident. Liveness should target a local failure that a restart can reasonably fix. Readiness may include an indispensable dependency, but if every replica becomes unready, capacity falls to zero. Agree on that tradeoff with the service owner and test dependency recovery too.
Design a testable correction
Measure the interval from container start to genuinely completed initialization across representative starts, including cold starts and load. Compare those measurements with events and configured timings. A startup probe can give initialization time without indefinitely delaying deadlock detection after startup. Its approximate budget is failureThreshold multiplied by periodSeconds; account for other delays and probe execution time. This is not an exact timing guarantee.
For an API that already implements suitable endpoints, a candidate might use /startup for initialization, /ready for serving capability and /live for an unrecoverable local failure. These paths are examples, not AKS-provided features. Verify their implementation, port, cost and failure behavior before configuring them. Do not make readiness always pass merely to speed up a rollout.
In a representative environment, test normal and slow starts, dependency failure and recovery, a genuinely stuck process, a slow response and a wrong port. Check Ready transitions, restarts, Service endpoints and a synthetic request separately. If initialization writes data or runs migrations, prove idempotency before deliberately triggering restarts.
Canary, decision and rollback
Prepare an isolated canary or limited revision using the team’s delivery controls, without replacing all healthy capacity. Record the prior manifest and digest, stop criteria, accountable owner and return procedure. A Deployment template change can initiate a rollout: treat it as a production change, not an inspection.
Observe at least a complete startup cycle and a representative traffic window: old and new replica availability, probe events, restart rate, latency and user-facing errors. Simulate dependency failure only in an explicitly authorized environment or scope. Green probes are not enough: check a no-side-effect transaction and the actual traffic path.
Promote gradually only if the agreed canary criteria hold. If restarts increase, available capacity falls or customer impact persists, stop promotion and return to the last healthy revision through the approved delivery procedure; then verify endpoints and a controlled real transaction. Rolling back the image does not undo a data migration or an external action. Use their separate recovery procedures. If the previous revision cannot operate against the current state, hold the change and agree a recovery with the service owner.