OpsCanary
kubernetesworkloadsPractitioner

Mastering Kubernetes Probes: Liveness, Readiness, and Startup Explained

5 min read Kubernetes DocsApr 28, 2026
Share
PractitionerHands-on experience recommended

Kubernetes probes exist to ensure your applications run smoothly in production. They help detect when applications become unhealthy and can automatically take corrective actions. Liveness probes are particularly important; they monitor long-running applications that might transition to a broken state, requiring a restart. Readiness probes, on the other hand, check if a container is ready to accept traffic, preventing requests from being sent to containers that aren't fully initialized. Startup probes are also available to check if an application has started successfully, which is useful for applications with long initialization times.

The kubelet performs health checks based on the defined probes. For liveness probes, if the command or HTTP request succeeds, the container is considered alive. If it fails, the kubelet kills and restarts the container. For instance, you can configure a liveness probe to execute a command like cat /tmp/healthy every 5 seconds after an initial delay of 5 seconds. If this command returns a non-zero value, the kubelet will restart the container. Key parameters include initialDelaySeconds, which determines how long to wait after the container starts before initiating the probe, and periodSeconds, which defines how often to perform the probe.

In production, understanding the nuances of these probes is vital. For example, in Kubernetes v1.13 and later, local HTTP proxy settings do not affect HTTP liveness probes, which can lead to unexpected behavior if you're relying on those settings. Always test your configurations to ensure they behave as expected under load and during failure scenarios.

Key takeaways

  • Configure liveness probes to automatically restart containers in broken states.
  • Use readiness probes to prevent traffic from reaching uninitialized containers.
  • Set `initialDelaySeconds` to manage when probes start checking container health.
  • Monitor the behavior of probes in production to catch unexpected issues.
  • Be aware that local HTTP proxy settings do not affect HTTP liveness probes in Kubernetes v1.13 and later.

Why it matters

Using liveness and readiness probes effectively can significantly reduce downtime and improve the reliability of your applications in production. They automate recovery processes, allowing your team to focus on other critical tasks.

Code examples

YAML
apiVersion:v1kind:Podmetadata:labels:test:livenessname:liveness-execspec:containers:-name:livenessimage:registry.k8s.io/busybox:1.27.2args:- /bin/sh- -c- touch /tmp/healthy; sleep 30; rm -f /tmp/healthy; sleep 600livenessProbe:exec:command:- cat- /tmp/healthyinitialDelaySeconds:5periodSeconds:5
YAML
apiVersion:v1kind:Podmetadata:labels:test:livenessname:liveness-httpspec:containers:-name:livenessimage:registry.k8s.io/e2e-test-images/agnhost:2.40args:- livenesslivenessProbe:httpGet:path:/healthzport:8080httpHeaders:-name:Custom-Headervalue:AwesomeinitialDelaySeconds:3periodSeconds:3
YAML
apiVersion:v1kind:Podmetadata:name:goproxylabels:app:goproxyspec:containers:-name:goproxyimage:registry.k8s.io/goproxy:0.1ports:-containerPort:8080readinessProbe:tcpSocket:port:8080initialDelaySeconds:15periodSeconds:10livenessProbe:tcpSocket:port:8080initialDelaySeconds:15periodSeconds:10

When NOT to use this

The official docs don't call out specific anti-patterns here. Use your judgment based on your scale and requirements.

Want the complete reference?

Read official docs

Test what you just learned

Quiz questions written from this article

Take the quiz →

Get the daily digest

One email. 5 articles. Every morning.

No spam. Unsubscribe anytime.