当前位置: 首页 > 知识库问答 >
问题:

Google Kubernetes入口健康检查总是失败

严烨
2023-03-14

我已经在端口80上配置了一个通过apache公开的web应用程序pod。我无法配置从internet访问的服务入口。问题是后端服务总是报告为不健康。

Pod配置:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  labels:
    name: webapp
  name: webapp
  namespace: my-app
spec:
  replicas: 1
  selector:
    matchLabels:
      name: webapp
  template:
    metadata:
      labels:
        name: webapp
    spec:
      containers:
      - image: asia.gcr.io/my-app/my-app:latest
        name: webapp
        ports:
        - containerPort: 80
          name: http-server

服务配置:

apiVersion: v1
kind: Service
metadata:
  name: webapp-service
spec:
  type: NodePort
  selector:
    name: webapp
  ports:
    - protocol: TCP
      port: 50000
      targetPort: 80

入口配置:

kind: Ingress
metadata:
  name: webapp-ingress
spec:
  backend:
    serviceName: webapp-service
    servicePort: 50000

这会导致后端服务报告为不健康。

健康检查设置:

Path: /
Protocol: HTTP
Port: 32463
Proxy protocol: NONE

共有1个答案

谭学名
2023-03-14

使用GKE,在创建入口时会自动创建html" target="_blank">负载平衡器上的运行状况检查。由于HC是自动创建的,所以防火墙规则也是自动创建的。

由于没有配置readinessProbe,LB创建了一个默认HC(您列出的那个)。为了正确地进行调试,您需要隔离故障点所在的位置。

首先,确保您的pod正确地服务于流量;

kubectl exec[pod_name]--wgetlocalhost:80

如果应用程序内置了curl,则可以使用它代替wget。如果应用程序既没有wget也没有curl,请跳到下一步。

>

  • 获取以下输出并跟踪输出: <块引用>

    kubectl获取po-l name=webapp-o wide
    kubectl获取svc webapp-service

    你需要保留服务和pod集群

    SSH到集群中的一个节点并运行sudo工具箱bash

    安装卷曲:

    apt-get安装curl'

    curl-I[pod\u clusterIP]:80

    这需要返回200的响应

    Curl-I[service_clusterIP]: 80

    如果pod没有返回200响应,则容器无法正常工作或pod上的端口未打开。

    如果pod正常工作,但服务不正常,则iptables中的路由存在问题,该路由由kube代理管理,这将是集群的问题。

    最后,如果pod和服务都正常工作,则负载均衡器健康检查存在问题,Google也需要调查一个问题。

  •  类似资料:
    • SOFABoot 为 Spring Boot 的健康检查能力增加了 Readiness Check 的能力。如果你需要使用 SOFA 中间件,那么建议使用 SOFABoot 的健康检查能力的扩展,来更优雅的上线应用实例 引入健康检查扩展 要引入 SOFABoot 的健康检查能力的扩展,只需要引入以下的 Starter 即可: <dependency> <groupId>com.alipay

    • 健康检查配置概述。 filter.http.HealthCheck filter.http.HealthCheck proto { "pass_through_mode": "{...}", "endpoint": "...", "cache_time": "{...}" } pass_through_mode (BoolValue, REQUIRED) 指定过滤器是否在传递模式下运

    • 健康检查架构概述。如果为集群配置了健康检查,则会发出相应的统计信息。详见请参考统计相关文档。 HealthCheck HealthCheck.Payload HealthCheck.HttpHealthCheck HealthCheck.TcpHealthCheck HealthCheck.RedisHealthCheck HealthCheck HealthCheck proto { "ti

    • 健康检查架构概述。 如果为集群配置了健康检查,则会发出相应的统计信息。并且记录在这里。 { "type": "...", "timeout_ms": "...", "interval_ms": "...", "unhealthy_threshold": "...", "healthy_threshold": "...", "path": "...", "send": [

    • 健康检查配置概述。 { "name": "health_check", "config": { "pass_through_mode": "...", "endpoint": "...", "cache_time_ms": "..." } } pass_through_mode (required, boolean) 指定过滤器是否在通过模式下运行。 end

    • 健康检查架构概述 如果为集群配置了健康检查,则会触发其他统计信息。详见这里文档。 v1 API文档 v2 API文档 TCP健康检查 注意:本文是为v1 API编写的,但这些概念也适用于v2 API。它将在未来版本中使用v2 API重写。 执行的匹配类型如下(这是MongoDB运行健康检查请求和响应): { "send": [ {"binary": "39000000"},