Startup readiness and liveness
Three questions about application health
A container can be running but still unable to answer requests. A probe is a check performed by the kubelet to learn something about a container. Startup asks whether initialization has completed; readiness asks whether the application can accept traffic now; liveness asks whether restarting the container is likely to recover it. In a bookstore service, loading a search index may take time, while a brief database outage may make requests fail without making the process itself irrecoverable. Use different checks for these different states.
Configure the three probes
The manifest below is a static, offline example for a hypothetical HTTP server. Its image is intentionally non-deployable. The server contract is /started returns success once initialization completes, /ready reports whether normal requests can be handled, and /live reports whether the process can still make progress. In an actual lab, provide a reviewed image implementing those endpoints. All checks use the named container port http, which resolves to 8080.
apiVersion: v1kind: Podmetadata: name: catalog-health namespace: book-labspec: containers: - name: catalog image: registry.invalid/bytemind/catalog:demo ports: - name: http containerPort: 8080 resources: requests: cpu: 250m memory: 128Mi limits: cpu: 500m memory: 256Mi startupProbe: httpGet: path: /started port: http periodSeconds: 5 failureThreshold: 12 timeoutSeconds: 2 readinessProbe: httpGet: path: /ready port: http periodSeconds: 5 failureThreshold: 2 timeoutSeconds: 2 livenessProbe: httpGet: path: /live port: http periodSeconds: 10 failureThreshold: 3 timeoutSeconds: 2The startup check allows 12 consecutive failures at five-second intervals before recovery is triggered; 60 seconds is a planning estimate, not a precise deadline. The readiness check tolerates one consecutive failure, and liveness tolerates two. Once startup succeeds, readiness and liveness become active.
How the kubelet interprets checks
HTTP probes regard status codes 200–399 as success; TCP checks establish a connection, not application correctness. An exec probe runs a command inside the container and uses its exit status (zero means success). A gRPC probe checks a server implementing the gRPC health checking protocol and requires a numeric port. It does not accept a named port. These methods are alternatives; choose one per probe. A startup check gates the other checks until its first success. A readiness failure marks the container not ready after its failure threshold and normally removes the Pod from regular Service traffic; it does not itself restart the container. A failed startup or liveness check triggers container termination and recovery subject to restart policy. The examples assume the ordinary Always policy.
Choose thresholds instead of guessing
periodSeconds controls the check interval; timeoutSeconds bounds an individual check; failureThreshold counts consecutive failures; successThreshold counts consecutive successes needed after failure (must be one for startup and liveness). initialDelaySeconds can delay initial checks. In practice, check duration, scheduling and readiness acceleration mean the product of interval and threshold is not an exact elapsed-time guarantee. Set values from observed startup and latency distributions; a probe is workload on the application. Do not query an expensive database on every liveness check. A dependency outage should usually make the service unready only if it cannot serve useful traffic; restarting every replica can make recovery worse.
Read a health scenario
In the offline cases, the first three startup checks fail and the fourth succeeds. The container is still initializing before that success. Later, two successive readiness checks fail: assume all other readiness conditions are satisfied and the ordinary Service excludes unready endpoints. The application stays running, but regular traffic should move to ready endpoints. Three consecutive liveness failures later trigger recovery of that container, not automatic creation of an entirely new Pod. An individual failure followed by success does not count as a continuing streak.
Inspect before changing probes
In an approved lab only, inspect the Pod description, events, current logs and, after a restart, previous container logs. The following commands are illustrations: replace the explicit lab context and namespace only after verifying the isolated environment. The placeholder Pod does not exist by default.
kubectl --context bytemind-lab -n book-lab describe pod catalog-healthkubectl --context bytemind-lab -n book-lab logs catalog-health -c catalog --previousThe previous log request may fail if there is no previous container instance. Look for probe failure events alongside restart count and state; a restart count alone does not identify its cause.
Practice and recap
Read catalog-health.yaml and probe-cases.json. Predict which failures should change readiness and which should trigger a restart. Explain how a slow startup differs from a temporary dependency outage. Do not apply these examples; the fixtures are designed for offline reasoning. Next, learn how resource settings affect placement and health.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Startup readiness and liveness — knowledge check
Apply the lesson concepts to original offline scenarios.
Which probe should allow a slow initial index load?
Two consecutive readiness failures reach the configured threshold. What is the direct consequence?
Which probe targets a process that can no longer make progress?
What does a successful TCP probe establish?
Why is checking a remote database in liveness often a poor choice?