An HTTP GET probe checks an application by sending a GET request to a container’s IP address, port, and path. A 2xx or 3xx response succeeds; an error response, timeout, or missing response fails. As a liveness probe, repeated failures can cause Kubernetes to terminate and restart the container when its restart policy allows. section 6.2.2
Configure the probe around the application endpoint and the lifecycle decision it supports:
- Use a simple path such as / on the application port when the application has no dedicated health endpoint. section 6.2.3
- Use a dedicated endpoint such as /ready on an administration port when a proxy exposes explicit health status; ports may be numeric or named. section 6.2.3
- Tune initialDelaySeconds, periodSeconds, timeoutSeconds, and failureThreshold to control when checks begin, how often they run, their timeout, and required consecutive failures. section 6.2.3
- Keep handlers lightweight and avoid retry loops; let failureThreshold provide repeated-failure tolerance. section 6.2.7
- Apply the same HTTP mechanism to readiness when the response should determine whether a service forwards connections to the pod. section 11.6.1
A liveness probe in a Pod manifest
A container serving HTTP on port 8080 can define httpGet with path / and port 8080. A proxy can instead check /ready on its named admin port, with a 10-second initial delay, 5-second period, 2-second timeout, and three-failure threshold. section 6.2.3
Listing 6.1 Adding a liveness probe to a pod
apiVersion: v1
kind: Pod
metadata:
name: kiada-liveness
spec:
containers:
- name: kiada
image: luksa/kiada:0.1
ports:
- name: http
containerPort: 8080
livenessProbe: #1
httpGet: #1
path: / #1
port: 8080 #1
- name: envoy
image: luksa/kiada-ssl-proxy:0.1
ports:
- name: https
containerPort: 8443
- name: admin
containerPort: 9901
livenessProbe: #2
httpGet: #2
path: /ready #2
port: admin #2
initialDelaySeconds: 10 #2
periodSeconds: 5 #2
timeoutSeconds: 2 #2
failureThreshold: 3 #2
Inspect the complete Pod manifest showing minimal and fully configured HTTP GET liveness probes. section 6.2.3
