Readiness and Liveness probe#
The readiness probe checks if the service in pod can accept traffic. Kubernetes will remove the pod if the readiness probe fails.
The liveness probe is used to check whether the pod is still alive and functioning. If the liveness check fails, the pod will be restarted by Kubernetes.
Types of readiness and liveness probe#
We can use HTTP, command or TCP probe.
Get configuration for liveness and readiness#
We can run the following command to get the pod configuration:
kubectl -n <your-namespace> get pod <your-pod-name> -o yaml
You will get the configuration for this pod in YAML format.
The liveness setting is under section livenessProbe
,
and the readiness setting is under section readinessProbe
.
You can also go to the GCP console (https://console.cloud.google.com/), select your projects.
Then go to Kubernetes Engine --> Workloads
, click your service name and go to the pod overview page.
Then you can click the YAML
tab page to see the configuration for this pod.
For the liveness probe, you will see something like this:
livenessProbe:
failureThreshold: 3
httpGet:
path: /health_check
port: 8080
scheme: HTTP
initialDelaySeconds: 15
periodSeconds: 5
successThreshold: 1
timeoutSeconds: 1
References#
- liveness, readiness probe: https://kubernetes.io/docs/concepts/configuration/liveness-readiness-startup-probes/
- configuration liveness and readiness: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/
- Kubernetes best practice, set up health check: https://cloud.google.com/blog/products/containers-kubernetes/kubernetes-best-practices-setting-up-health-checks-with-readiness-and-liveness-probes?hl=en