2

I am using readinessprobe for rolling updates. It works fine. But even after pods comes up. It keeps pinging healthz even after pod is running. I was assuming it will stop pinging when pods are up and running. Is it right?

specs:
   containers:
   - name: ready
     readinessProbe:
    httpGet:
      path: /healthz
      port: 80
Hacker
  • 7,798
  • 19
  • 84
  • 154

2 Answers2

3

The kubelet will continue to run this check every 10 second which is default value. You can customize it according to your need.

It's important data for kubelet to understand if the Container is healthy or not. if it is not healthy it will try to restart it. therefore, its a continuous process. that's how we try to achieve application availability

periodSeconds: How often (in seconds) to perform the probe. Default to 10 seconds. Minimum value is 1.

For further detail configure-probes

Suresh Vishnoi
  • 17,341
  • 8
  • 47
  • 55
  • 1
    Then how different is it when using liveness probe? It does same right? – Hacker Apr 18 '19 at 13:02
  • With liveness, I answer, "Hey I can breath , I am alive" with readiness I answer " I can reply to your response" these are two different thing. its similar for the application it try to get the configmap,secret and other environement values to initialize itself after than its ready to response – Suresh Vishnoi Apr 18 '19 at 13:05
  • An Application needs to go be pass liveness check to be up and rediness check to be running( mean it can respond to requests from the clients). then we have here an up and running application – Suresh Vishnoi Apr 18 '19 at 13:07
  • hopefully, you understand the the different purpose of these probes ? – Suresh Vishnoi Apr 18 '19 at 13:09
  • Say my pod stops responding on readiness probe, does it stop and start another pod or just shuts the connection to pod? – Hacker Apr 18 '19 at 13:40
  • Here we use `failureThreshold: 3` so if kubelet get 3 times unsuccessful response , it understand that container is not healthy, it will restart the pod – Suresh Vishnoi Apr 18 '19 at 13:44
  • Being restarted when the container is not healthy is a good feature of container – Suresh Vishnoi Apr 18 '19 at 13:45
  • Got it. ReadinessProbe is for application health and liveness is for pod health. I have below scenario, i run an API server. Say my server goes down because of some code failure, readiness probe will kick in and detect it and will restart after 3 attempts. Not sure under which scenario liveness probe will kick in. Do u have a scenario., – Hacker Apr 18 '19 at 14:08
  • https://cloud.google.com/blog/products/gcp/kubernetes-best-practices-setting-up-health-checks-with-readiness-and-liveness-probes – Suresh Vishnoi Apr 18 '19 at 14:19
3

readinessProbe and livenessProbe will continue to do the check depends on the periodSeconds you have set or default value which is 10 seconds.

readinessProbe and livenessProbe do the exact same thing. The difference is the actions to be performed in case of failure.

readinessProbe will shut the communication down with the service in case of failure - so that service does not send any request to the Pod.

livenessProbe will restart the Pod in case of failure.

vins
  • 15,030
  • 3
  • 36
  • 47