Google Kubernetes Ingress健康检查始终失败

我已经配置了通过端口80上的apache公开的Web应用程序pod。我无法配置用于从Internet访问的服务+入口。问题在于后端服务始终报告为“不正常”。

pod Config:

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

其他信息:我尝试了另一种方法来将部署作为具有外部IP的负载平衡器公开,并且效果很好。尝试使用NodePort + Ingress时,此问题仍然存在。

y5123768 回答:Google Kubernetes Ingress健康检查始终失败

使用GKE,在创建入口时会自动创建负载均衡器上的运行状况检查。由于HC是自动创建的,因此防火墙规则也是自动创建的。

由于没有配置readinessProbe,因此LB将创建一个默认的HC(您列出的HC)。为了正确地调试它,您需要隔离故障点在哪里。

首先,请确保您的pod能够正确提供流量;

kubectl exec [pod_name] -- wget localhost:80

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

  1. 获取以下输出并跟踪输出:
      

    kubectl get po -l name = webapp -o wide
      kubectl获取svc webapp服务

您需要保留服务和pod群集IP

  1. SSH到群集中的节点并运行sudo toolbox bash

  2. 安装curl:

  

apt-get install curl`

  1. 测试Pod,以确保它们正在群集中提供流量:
  

curl -I [pod_clusterIP]:80

这需要返回200响应

  1. 测试服务:
  

curl -I [service_clusterIP]:80

如果容器未返回200响应,则表明容器未正确工作或容器上的端口未打开。

如果pod正常工作,但服务无效,则iptables中的路由存在问题,该路由由kube-proxy管理,并且可能是集群的问题。

最后,如果pod和服务都正常工作,则说明负载均衡器运行状况检查存在问题,还需要Google调查此问题。

本文链接:https://www.f2er.com/3161166.html

大家都在问