2

我正在使用带有以下配置的入口为 GKE 上的 consul ui 创建一个负载均衡器

apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: public-apis
spec:
  rules:
    - host: consul.example.com
      http:
        paths:
          - path: /ui/
            pathType: Prefix
            backend:
              serviceName: hashicorp-consul-ui
              servicePort: http

该服务hashicorp-consul-ui是 clusterIP 类型的服务。

另外,我正在创建以下 backendConfig

apiVersion: cloud.google.com/v1
kind: BackendConfig
metadata:
  name: consul-ui-backendconfig
spec:
  healthCheck:
    type: HTTP
    requestPath: /v1/health/state/failed
    port: 80

我将以下注释添加到 clusterIP 服务hashicorp-consul-ui

'cloud.google.com/backend-config': '{"ports": {"80":"consul-ui-backendconfig"}}'

这个 backendConfig 为 ingress 创建的后端服务创建健康检查,这个端点返回 200。但是健康检查失败并且 ingress 处于 Unhealthy 状态

我已经启用了健康检查日志,并且我在 NEG 上获得了以下日志

healthCheckProbeResult: {
   detailedHealthState: "TIMEOUT"    
   healthCheckProtocol: "HTTP"    
   healthState: "UNHEALTHY"    
   ipAddress: "10.24.1.30"    
   previousDetailedHealthState: "UNKNOWN"    
   previousHealthState: "UNHEALTHY"    
   probeCompletionTimestamp: "2021-02-14T03:31:43.337063261Z"    
   probeRequest: "/v1/health/state/failed"    
   probeResultText: "HTTP response: , Error: Connection refused"    
   probeSourceIp: "35.191.9.211"    
   responseLatency: "0.001265s"    
   targetIp: "10.24.1.30"    
   targetPort: 80    
}

另外,不知道为什么我只得到这个日志一次,我不应该定期得到这些日志吗?

另外,谁能指导我如何解决这个 healthCheck 问题?

4

1 回答 1

-1

Consul API/UI 默认侦听端口 8500,或在集群中启用 TLS 时侦听 8501。

将您的入口更改servicePort为使用端口 8500。这应该可以解决连接问题。

---
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: public-apis
spec:
  rules:
    - host: consul.example.com
      http:
        paths:
          - path: /ui/
            pathType: Prefix
            backend:
              serviceName: hashicorp-consul-ui
              servicePort: 8500
于 2021-02-19T21:04:25.583 回答