Kubernetes Liveness, Readiness Probe Explained

Sarun Nuntaviriyakul
4 min readJul 2, 2022

In Kubernetes, other than the restartPolicy which defaults to restart the pod when a pod fails. There are Liveness and Readiness probes to control and manage the lifecycle of a pod.

Liveness Probe

A liveness Probe is used by the kubelet to know when to restart the container inside a pod. This probe can help restart the container when the application is not responding to the request or the response time is too long.

There are 3 main ways to check the container’s health using a liveness probe.

  1. Liveness command
apiVersion: v1
kind: Pod
metadata:
name: webserver
spec:
containers:
- name: nginx
image: nginx:latest
livenessProbe:
exec:
command:
- cat
- /tmp/healthy
initialDelaySeconds: 3
periodSeconds: 30

We are creating a nginx container inside the pod webserver. The container has a livenessProbe attached to it.

exec:
command:
- cat
- /tmp/healthy

If the command under exec fails the kubelet will restart the container. In this case, if…

--

--