Kubernetes HealthCheck 不会通过一项服务。入口配置错误?
我有以下入口设置:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: owl-dev-ingress
annotations:
kubernetes.io/ingress.global-static-ip-name: zzapps-owl-dev-ip
networking.gke.io/managed-certificates: managed-cert
kubernetes.io/ingress.class: 'gce'
spec:
rules:
- host: owl-dev.zzapps.nl
http:
paths:
- path: /api
pathType: Prefix
backend:
service:
name: zzapps-owl-dev-webapi-service
port:
number: 80
- path: /
pathType: Prefix
backend:
service:
name: zzapps-owl-dev-webui-service
port:
number: 3000
它公开 2 个服务:如果使用 /api 调用 url,它会转发到端口 80 上的 API 后端部署,如果它转到 /*,它会转发到为网页提供服务的 UI pod。
是的,后端服务对于 api 来说不健康(在 80 上):
当我检查健康检查本身时:
它在 /api
上配置。这也是后端所期望的。 当我通过 gcloud shell 暴露后端并转发它时,我可以很好地到达 /api
(localhost:8080/api
) (它提供了一个 swagger 页面,带有 200结果,我认为可以吗?)
gcloud container clusters get-credentials xxx-xxx-xxx-2 --zone europe-west4-a --project xxx-xxx-xxx \
> && kubectl port-forward $(kubectl get pod --selector="app=zzapps-owl-dev-web-api" --output jsonpath='{.items[0].metadata.name}') 8080:80
Fetching cluster endpoint and auth data.
kubeconfig entry generated for xxx-xxx-xxx-2.
To take a quick anonymous survey, run:
$ gcloud survey
Forwarding from 127.0.0.1:8080 -> 80
Forwarding from [::1]:8080 -> 80
Handling connection for 8080
长话短说: 目前尚不清楚健康检查为何无法验证连接。
I have the following ingress setup:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: owl-dev-ingress
annotations:
kubernetes.io/ingress.global-static-ip-name: zzapps-owl-dev-ip
networking.gke.io/managed-certificates: managed-cert
kubernetes.io/ingress.class: 'gce'
spec:
rules:
- host: owl-dev.zzapps.nl
http:
paths:
- path: /api
pathType: Prefix
backend:
service:
name: zzapps-owl-dev-webapi-service
port:
number: 80
- path: /
pathType: Prefix
backend:
service:
name: zzapps-owl-dev-webui-service
port:
number: 3000
It exposes 2 services: if the url is called with /api it forwards to the API backend deployment on port 80, if it goes to /* it forwards to the UI pod serving the webpage.
The / works fine, except that the Ingress shows
And yes, the backend service is unhealthy for the api (on 80):
When I check the healthcheck itself:
It is configured on /api
. This is what the backend is expecting as well.
When I expose the backend through the gcloud shell and forward it, I can reach /api
fine (localhost:8080/api
) (it gives a swagger page, with a 200 result, I think that is okay?)
gcloud container clusters get-credentials xxx-xxx-xxx-2 --zone europe-west4-a --project xxx-xxx-xxx \
> && kubectl port-forward $(kubectl get pod --selector="app=zzapps-owl-dev-web-api" --output jsonpath='{.items[0].metadata.name}') 8080:80
Fetching cluster endpoint and auth data.
kubeconfig entry generated for xxx-xxx-xxx-2.
To take a quick anonymous survey, run:
$ gcloud survey
Forwarding from 127.0.0.1:8080 -> 80
Forwarding from [::1]:8080 -> 80
Handling connection for 8080
Long story short:
It is unclear why the healthcheck is not able to verify connection.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的,
我的后端服务在 /api 上进行了 301 重定向,到 /api/
抱歉,但最好先检查确切的响应:)
Okay,
my backend service gave a 301 redirect on /api, to /api/
Sorry, but it is good to check the exact responses first :)