How add nginx-ingress custom health check behind a nginx reverse proxy

2/5/2020

I have a nginx server outside kubernetes. nginx -> nginx ingress. I want know how add a custom health check path /health/status to nginx ingress.

-- quanwei li
kubernetes
nginx

1 Answer

2/5/2020

This question is almost certainly solving the wrong problem, but in the spirit of answering what was asked:

You can expose the Ingress /healthz to the outside world:

kind: Service
metadata:
  name: ingress-nginx-health
spec:
  type: ClusterIP
  selector: # whatever
  ports:
  - name: healthz
    port: 80
    targetPort: 10254
---
kind: Ingress
spec:
  rules:
  - host: elb-1234.example.com
    http:
      path: /healthz
      backend:
        serviceName: ingress-nginx-health
        servicePort: healthz

Because if your Ingress controller falls over, it will for sure stop answering its own healthz check

-- mdaniel
Source: StackOverflow