How can we restart the Kubernetes pod if its readiness fail

3/13/2019

a quick question. I know if the Kubernetes liveness probe fails, kubernetes will help restart the pod and try again. But how about the readiness probe fails? How can I also ask kubernetes to restart the pod?

api-group-0 0/1 Running 0 6h35m

Restart this pod can make it works. Thanks all!

-- JordanZT
kubernetes
kubernetes-pod

1 Answer

3/20/2019

There's no way to trigger pod restart within a readiness probe. As it was recommended in the comments, you should rely on liveness probe instead.

livenessProbe:
      exec:
        command:
        - /opt/fissile/readiness-probe.sh
      initialDelaySeconds: 20
      periodSeconds: 10
      failureThreshold: 3

If you have concerns about readiness-probe.sh fails periodically and shouldn't trigger restart straight after the first failure, consider failureThreshold setting. It will give this many tries before pod restart.

-- A_Suh
Source: StackOverflow