【问题标题】:GCE health check not working with ingress nginx controllerGCE 健康检查不适用于入口 nginx 控制器
【发布时间】:2021-02-12 19:59:30
【问题描述】:

我正在一个具有 3 个节点的 GKE 集群 v1.17.12-gke.1504 上安装 nginx 入口控制器 (k8s.gcr.io/ingress-nginx/controller:v0.40.2)。

ingress-nginx-controller 部署为 Deployment;我不想将它部署为 DaemonSet,因为我将来会有一个包含许多节点的集群,这会浪费资源。

kubernetes 资源的创建正常完成,并且在 GCE 中创建了负载均衡器,但相关的健康检查显示为失败。

我已经访问了每个集群节点来检查健康检查的端点,我发现它只在创建了 ingress-nginx-controller pod 的节点上工作。

在 pod 被提升的节点中,它返回 200:

$ curl localhost:32203/healthz -v
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 32203 (#0)
> GET /healthz HTTP/1.1
> Host: localhost:32203
> User-Agent: curl/7.64.1
> Accept: */*
>
< HTTP/1.1 200 OK
< Content-Type: application/json
< Date: Fri, 30 Oct 2020 09:03:42 GMT
< Content-Length: 111
<
{
        "service": {
                "namespace": "ingress-nginx",
                "name": "ingress-nginx-controller"
        },
        "localEndpoints": 1
* Connection #0 to host localhost left intact
}* Closing connection 0

但在 pod 未启动的节点上,它会返回 503:

~ $ curl localhost:32203/healthz -v
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 32203 (#0)
> GET /healthz HTTP/1.1
> Host: localhost:32203
> User-Agent: curl/7.64.1
> Accept: */*
>
< HTTP/1.1 503 Service Unavailable
< Content-Type: application/json
< Date: Fri, 30 Oct 2020 09:03:20 GMT
< Content-Length: 111
<
{
        "service": {
                "namespace": "ingress-nginx",
                "name": "ingress-nginx-controller"
        },
        "localEndpoints": 0
* Connection #0 to host localhost left intact
}* Closing connection 0

如何在不必从每个节点上的 ingress-nginx-controller 提升 pod 的情况下进行运行状况检查?

【问题讨论】:

    标签: kubernetes google-kubernetes-engine kubernetes-health-check


    【解决方案1】:

    问题是我在服务中配置了externalTrafficPolicy: "Local"

    https://kubernetes.io/docs/tutorials/services/source-ip/

    【讨论】:

      猜你喜欢
      • 2019-03-05
      • 2017-08-19
      • 1970-01-01
      • 2016-03-28
      • 1970-01-01
      • 2020-06-09
      • 1970-01-01
      • 2018-06-19
      • 2019-01-21
      相关资源
      最近更新 更多