All probe fields are the same as readiness probes. The only difference is using the
livenessProbe field instead of readinessProbe.What are liveness probes?
Liveness probes determine whether a container is alive. If the probe fails, kubelet restarts the container. This is useful when a container is running but the application inside is no longer responding — for example, an API server that is stuck but whose process has not exited. A successful probe means the container is healthy. A failed probe triggers a container restart. Probe types:HTTP
Sends an HTTP GET request to the container. A 2xx or 3xx response is healthy.
TCP
Opens a TCP socket to the container. A successful connection is healthy.
exec
Runs a command inside the container. An exit code of
0 is healthy.Usage
- HTTP
- TCP
- exec
liveness-probes.yaml
Key probe fields
| Field | Description |
|---|---|
initialDelaySeconds | Seconds to wait after the container starts before the first probe |
periodSeconds | How often the probe is performed |
failureThreshold | Number of consecutive failures before the container is restarted (default: 3) |