-1

can someone give an example or explain the difference between the liveness endpoint and the readiness endpoint for a webapp, that has a /ping endpoint that returns pong.

Do I need different probes here at all? I read in this blogpost https://komodor.com/learn/kubernetes-liveness-probes-a-practical-guide/ "You can use liveness and readiness probes on the same endpoint, but in this case, use the readiness probe to check startup behavior and the liveness probe to determine container health (in other words, downtime)"

But what would that mean regarding the implementation? higher initial delay seconds for readiness? and lower failurethreshold for liveness; e.g:

livenessProbe:
  httpGet:
    path: /health
    port: 8080
  periodSeconds: 10
  failureThreshold: 6
readinessProbe:
  httpGet:
    path: /health
    port: 8080
  periodSeconds: 30
  initialDelaySeconds: 10
  failureThreshold: 3

or can I just dismiss liveness test, as I do not expect a deadlock event and the container restarts anyway when PID1 breaks?

mafra
  • 1
  • 1
  • Can you give us more details about how the existing documentation and examples are unclear? – larsks Jan 24 '23 at 18:38
  • Hi @larsks, what is unclear to me: how would you implement (periodSeconds, failurethreshold) for the mentioned ping application? would you use readiness at all (since deadlock not really possible) and if, how would you configure it compared to liveness probe (what would be different) – mafra Jan 24 '23 at 19:21
  • also added question slightly – mafra Jan 26 '23 at 08:22
  • "You can use liveness and readiness probes on the same endpoint", this is totally a wrong statement. See https://danielw.cn/health-check-probes-in-k8s – Daniel Feb 15 '23 at 17:55
  • thanks, Daniel. This answer is the first one which some new info for me – mafra Feb 18 '23 at 18:18

1 Answers1

0

Liveness and readiness probes are Kubernetes features that allow you to check the health and availability of your application running in a container. They are used to detect when an application is not running correctly and take appropriate action, such as restarting the container.

A Liveness probe is used to check if the application is still running and responsive. A readiness probe is used to check if the application is ready to receive traffic.

You need to experiment with the different values as per your needs of the application.

Here is how you can configure the probes on the same endpoint

livenessProbe:
  httpGet:
    path: /health
    port: 8080
  periodSeconds: 10
  failureThreshold: 3
readinessProbe:
  httpGet:
    path: /health
    port: 8080
  periodSeconds: 30
  initialDelaySeconds: 20
  failureThreshold: 2

The readiness probe can check the /health endpoint every 30 seconds with a failure threshold of 2 and an initial delay of 20 seconds, while the liveness probe can check the endpoint every 10 seconds with a failure threshold of 3 for both. In this manner, after waiting for 30 seconds, the readiness probe will determine whether the container is prepared to receive traffic, enabling the container to start up.

If the probe fails 3 times consecutively, the container will be considered not healthy and will be restarted.