Search code examples
kubernetesreadinessprobe

How to connect http response to readiness and liveness probes


I try to restart the pod when an endpoint returns an HTTP 500 on the /health endpoint. The service, probe-pod, should never send traffic to the pod while it is failing.

  • The application needs to has an endpoint /start, which will indicate if it can accept traffic by returning an HTTP 200. If the endpoint returns an HTTP 500, the application has not finished initialization
  • The application needs to have another endpoint /health that will indicate if the application is still working as expected by returning an HTTP 200. If the endpoint returns an HTTP 500 the application is no longer responsive.
  • The probes should use port 8080

I know how the readiness and liveness probe works but how to connect their response base of output? I can't solve the first and second items. How could I test the solution? Could anyone help me?


Solution

  • The following way you can choose I guess, also refer to this link for clarity

     livenessProbe:
          httpGet:
            path: /health
            port: 8080
          initialDelaySeconds: as-required-by-you
        
     readinessProbe:
          httpGet:
            path: /start
            port: 8080