Search code examples
kuberneteshttp-headersmarathon

How to ignore http requests health check in kubernetes within liveness probe / readiness probe?


I am working on migrating one of the application to kubernetes. I want to discard the result if the health check returns http(100-199).

Similar to one which we have in marathon

IgnoreHttp1xx (Optional. Default: false): Ignore HTTP informational status codes 100 to 199. If the HTTP health check returns one of these, the result is discarded and the health status of the task remains unchanged.

How can i achieve this in kubernetes? Does it accept if i pass like this?

  livenessProbe:
    httpGet:
      path: /v1/health
      port: 9102
      scheme: HTTP
      httpHeaders:
       - name: ignoreHttp1xx
         value: false

Unfortunately i have no way to test this in our environment. Does it ignore such requests? If not what is the alternative i can use for this.


Solution

  • Any code greater than or equal to 200 and less than 400 indicates success. Any other code indicates failure. You can see the source code for the server in server.go.

    https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/#configure-probes

    Maybe you can change your healthcheck to return something between 200-300 when it is going to return 100-199 , kind of overwirte.