使用 Ingress 服务类型将 "express-gateway" 部署到 Google Kubernetes Engine 时出现问题

Problem deploying "express-gateway" to Google Kubernetes Engine with Ingress service type

我正在向 GKE 部署一个微服务 nodejs express 应用程序,我成功部署了这些服务(一个作为具有静态 IP @ 的 Ingress 服务,一个作为不会暴露给 Internet 的 NodePort 服务)。

现在我正在尝试部署 api 网关,它是一个快速网关应用程序,我第一次将它部署为 LoadBalancer 服务并且它正在运行,这是我的服务代码:

apiVersion: v1
kind: Service
metadata:
  name: express-gateway-balancer
spec:
  selector:
    app: express-gateway
  type: LoadBalancer
  ports:
    - protocol: TCP
      port: 80
      targetPort: 8080

现在我必须将流量转换为 HTTPS 才能调用 API 端点前端我的反应前端应用程序是 运行 HTTPS,所以我做了一个研究,方法是公开api 网关应用程序作为 Ingress 而不是 LoadBalancer。

所以我做了更改(与我对其余部署所做的相同)并创建了一个静态 IP @ "gateway-ip" 以通过 Ingress 公开它:

这是我的 service.yaml 文件:

apiVersion: v1
kind: Service
metadata:
  name: express-gateway-service
spec:
  selector:
    app: express-gateway
  type: NodePort
  ports:
    - protocol: TCP
      port: 80
      targetPort: 8080

我的 Ingress.yaml 文件:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: gateway-service-ingress
  annotations:
    kubernetes.io/ingress.global-static-ip-name: "gateway-ip"
spec:
  backend:
    serviceName: express-gateway-service
    servicePort: 80

这是我的部署文件:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: express-gateway
  labels:
    app: express-gateway
spec:
  selector:
    matchLabels:
      app: express-gateway
  replicas: 3
  template:
    metadata:
      labels:
        app: express-gateway
    spec:
      containers:
        - name:  express-gateway
          image: gcr.io/PROJECT_ID/apigatewayservice:v1
          ports:
            - name: gateway
              containerPort: 8080
            - name: admin
              containerPort: 9876

这是我得到的错误的屏幕截图:

有什么解决办法吗?谢谢

您是否有所有计划的默认端点 pods?我是说 ”/” ? Ingress 执行内置的健康检查就绪概率检查“/”是否可达。如果不是,它会宣布它不健康。 希望这有帮助。