首页 > 解决方案 > How add nginx-ingress custom health check behind a nginx reverse proxy

问题描述

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.

标签: nginxkubernetes

解决方案


这个问题几乎肯定是在解决错误的问题,但本着回答所问问题的精神:

您可以将 Ingress 暴露/healthz给外界:

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

因为如果你的 Ingress 控制器摔倒了,它肯定会停止回答自己的 healthz 检查


推荐阅读