Pushpendra
Pushpendra

Reputation: 55

How kubernetes handle livenessProbe failure?

I want to understand what happens behind the scene if a liveness probe fails in kubernetes ?

Here is the context:

We are using Helm Chart for deploying out application in Kubernetes cluster.

We have a statefulsets and headless service. To initialize mTLS, we have created a 'job' kind and in 'command' we are passing shell & python scripts are an arguments.

We have written a 'docker-entrypoint.sh' inside 'docker image' for some initialization work.

Inside statefulSet, we are passing a shell script as a command in 'livenessProbe' which runs every 30 seconds.

I want to know if my livenessProbe fails for any reason : 1. Does helm chart monitor this probe & will restart container or it's K8s responsibility ? 2. Will my 'docker-entryPoint.sh' execute if container is restarted ? 3. Will 'Job' execute at the time container restart ?

How Kubernetes handles livenessProbe failure and what steps it takes?

Upvotes: 0

Views: 688

Answers (2)

Sunjay Jeffrish
Sunjay Jeffrish

Reputation: 91

To answer your question liveness probe and readiness probe are actions basically get calls to your application pod to check whether it is healthy. This is not related to helm charts. Once the liveness or readiness probe fails container restart takes place . I would say these liveness probes failure can affect your app uptime, so use a rolling deployment and autoscale your pod counts to enable availability.

Upvotes: 4

Arghya Sadhu
Arghya Sadhu

Reputation: 44687

  1. It's not helm's responsibility.It's kubernetes's responsibility to restart the pod in case of readiness probe failure.
  2. Yes docker-entryPoint.sh is executed at container startup.
  3. Job needs to be applied again to the cluster for it to execute. Alternatively you could use initcontainer which is guaranteed to run before the main container starts.
  4. Kubelet kills the container and restarts it if liveness probe fails.

Upvotes: 4

Related Questions