Kubernetes HealthCheck 不会通过一项服务。入口配置错误?

发布于 2025-01-09 04:59:24 字数 2082 浏览 1 评论 0原文

我有以下入口设置:

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 enter image description here

And yes, the backend service is unhealthy for the api (on 80):

enter image description here

When I check the healthcheck itself:

enter image description here

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

何以笙箫默 2025-01-16 04:59:24

好的,

我的后端服务在 /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 :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文