简体   繁体   English

使用 Ingress 服务类型将“express-gateway”部署到 Google Kubernetes 引擎时出现问题

[英]Problem deploying “express-gateway” to Google Kubernetes Engine with Ingress service type

I'm deploying a microservices nodejs express application to GKE, I successfully deployed the services (one as Ingress service with static IP @ and one as NodePort service which will not be exposed to Internet).我正在向 GKE 部署一个微服务 nodejs express 应用程序,我成功部署了这些服务(一个作为带有 static IP @ 的 Ingress 服务和一个作为不会暴露给 Internet 的 NodePort 服务)。

Now I'm trying to deploy the api gateway which is an express-gateway application, I deployed it in first time as a LoadBalancer service and it's working, here is my service code:现在我正在尝试部署 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

负载平衡器服务

Now I must transform the trafic to HTTPS to be able to call the API endpoints front my react frontend application which is running with HTTPS, so I did a research and the way is to expose the api gateway application as an Ingress not LoadBalancer. Now I must transform the trafic to HTTPS to be able to call the API endpoints front my react frontend application which is running with HTTPS, so I did a research and the way is to expose the api gateway application as an Ingress not LoadBalancer.

So I did the changes (the same I did with the rest of my deployments)and created a static IP @ "gateway-ip" to expose it via Ingress:所以我做了更改(我对部署的 rest 所做的相同)并创建了一个 static IP @“gateway-ip”以通过 Ingress 公开它

Here is my service.yaml file:这是我的 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

My Ingress.yaml file:我的 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

Here is my deployment file:这是我的部署文件:

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

Here are screenshot of the error I got:这是我得到的错误的屏幕截图:

服务错误控制台 服务错误浏览器

Any solutions?有什么解决办法吗? Thanks谢谢

Do you have a default endpoint of all your scheduled pods?您是否有所有计划的 pod 的默认端点? I mean "/"?我是说 ”/”? Ingress does the health check readiness prob inbuilt that checks if "/" is reachable or not. Ingress 会执行内置的健康检查准备情况,检查“/”是否可访问。 If not, it will declare it as unhealthy.如果不是,它将宣布它不健康。 Hope this helps.希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM