具有容器原生负载平衡的 GKE Ingress 未检测到健康检查(字段 'resource.httpHealthCheck' 的值无效)
GKE Ingress with container-native load balancing does not detect health check (Invalid value for field 'resource.httpHealthCheck')
我是 运行 Google Kubernetes Engine 上的一个集群,我目前正在尝试从使用具有外部负载平衡(和 NodePort 服务)的 Ingress 切换到具有容器原生负载的 Ingress遵循本文档的平衡(和 ClusterIP 服务):Container native load balancing
为了与我的服务进行通信,我使用了以下入口配置,该配置在使用 NodePort 服务而不是 ClusterIP 时工作得很好:
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: mw-ingress
annotations:
kubernetes.io/ingress.global-static-ip-name: mw-cluster-ip
networking.gke.io/managed-certificates: mw-certificate
kubernetes.io/ingress.allow-http: "false"
spec:
rules:
- http:
paths:
- path: /*
backend:
serviceName: billing-frontend-service
servicePort: 80
- path: /auth/api/*
backend:
serviceName: auth-service
servicePort: 8083
现在按照文档,我没有使用 readinessProbe 作为容器部署的一部分作为健康检查,而是转而使用 ClusterIP 服务和 BackendConfig。对于每个部署,我都使用这样的服务:
apiVersion: v1
kind: Service
metadata:
labels:
app: auth
name: auth-service
namespace: default
annotations:
cloud.google.com/backend-config: '{"default": "auth-hc-config"}'
spec:
type: ClusterIP
selector:
app: auth
ports:
- port: 8083
protocol: TCP
targetPort: 8083
和后端配置:
apiVersion: cloud.google.com/v1
kind: BackendConfig
metadata:
name: auth-hc-config
spec:
healthCheck:
checkIntervalSec: 10
port: 8083
type: http
requestPath: /auth/health
作为参考,这是 readinessProbe 以前的样子:
readinessProbe:
failureThreshold: 3
httpGet:
path: /auth/health
port: 8083
scheme: HTTP
periodSeconds: 10
现在进入实际问题。我首先部署了容器和服务,它们似乎启动得很好。然而,入口似乎没有正确地进行健康检查并在云控制台中显示:
Error during sync: error running backend syncing routine: error ensuring health check: googleapi: Error 400: Invalid value for field 'resource.httpHealthCheck': ''. HTTP healthCheck missing., invalid
集群和节点池都是 运行 GKE 版本 1.17.6-gke.11,所以注释 cloud.google.com/neg: '{"ingress": true}'
不是必需的。我已经检查并正确注释了该服务:
Annotations: cloud.google.com/backend-config: {"default": "auth-hc-config"}
cloud.google.com/neg: {"ingress":true}
cloud.google.com/neg-status: {"network_endpoint_groups":{"8083":"k8s1-2078beeb-default-auth-service-8083-16a14039"},"zones":["europe-west3-b"]}
我已经尝试重新创建集群和节点池,但没有效果。关于如何解决这个问题的任何想法?我在某处错过了额外的健康检查吗?
我发现了我的问题。显然,BackendConfig 的 type
属性区分大小写。一旦我将它从 http
更改为 HTTP
它在我重新创建入口后就起作用了。
我是 运行 Google Kubernetes Engine 上的一个集群,我目前正在尝试从使用具有外部负载平衡(和 NodePort 服务)的 Ingress 切换到具有容器原生负载的 Ingress遵循本文档的平衡(和 ClusterIP 服务):Container native load balancing
为了与我的服务进行通信,我使用了以下入口配置,该配置在使用 NodePort 服务而不是 ClusterIP 时工作得很好:
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: mw-ingress
annotations:
kubernetes.io/ingress.global-static-ip-name: mw-cluster-ip
networking.gke.io/managed-certificates: mw-certificate
kubernetes.io/ingress.allow-http: "false"
spec:
rules:
- http:
paths:
- path: /*
backend:
serviceName: billing-frontend-service
servicePort: 80
- path: /auth/api/*
backend:
serviceName: auth-service
servicePort: 8083
现在按照文档,我没有使用 readinessProbe 作为容器部署的一部分作为健康检查,而是转而使用 ClusterIP 服务和 BackendConfig。对于每个部署,我都使用这样的服务:
apiVersion: v1
kind: Service
metadata:
labels:
app: auth
name: auth-service
namespace: default
annotations:
cloud.google.com/backend-config: '{"default": "auth-hc-config"}'
spec:
type: ClusterIP
selector:
app: auth
ports:
- port: 8083
protocol: TCP
targetPort: 8083
和后端配置:
apiVersion: cloud.google.com/v1
kind: BackendConfig
metadata:
name: auth-hc-config
spec:
healthCheck:
checkIntervalSec: 10
port: 8083
type: http
requestPath: /auth/health
作为参考,这是 readinessProbe 以前的样子:
readinessProbe:
failureThreshold: 3
httpGet:
path: /auth/health
port: 8083
scheme: HTTP
periodSeconds: 10
现在进入实际问题。我首先部署了容器和服务,它们似乎启动得很好。然而,入口似乎没有正确地进行健康检查并在云控制台中显示:
Error during sync: error running backend syncing routine: error ensuring health check: googleapi: Error 400: Invalid value for field 'resource.httpHealthCheck': ''. HTTP healthCheck missing., invalid
集群和节点池都是 运行 GKE 版本 1.17.6-gke.11,所以注释 cloud.google.com/neg: '{"ingress": true}'
不是必需的。我已经检查并正确注释了该服务:
Annotations: cloud.google.com/backend-config: {"default": "auth-hc-config"}
cloud.google.com/neg: {"ingress":true}
cloud.google.com/neg-status: {"network_endpoint_groups":{"8083":"k8s1-2078beeb-default-auth-service-8083-16a14039"},"zones":["europe-west3-b"]}
我已经尝试重新创建集群和节点池,但没有效果。关于如何解决这个问题的任何想法?我在某处错过了额外的健康检查吗?
我发现了我的问题。显然,BackendConfig 的 type
属性区分大小写。一旦我将它从 http
更改为 HTTP
它在我重新创建入口后就起作用了。