gpt4 book ai didi

node.js - 使用Ingress服务类型将 “express-gateway”部署到Google Kubernetes Engine时出现问题

转载 作者:行者123 更新时间:2023-12-02 12:01:08 25 4
gpt4 key购买 nike

我正在将微服务nodejs express应用程序部署到GKE,我成功部署了这些服务(一个作为具有静态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

LoadBalancer Service

现在,我必须将流量转换为HTTPS,才能在与HTTPS一起运行的我的react前端应用程序前面调用API端点,因此我进行了研究,方法是将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

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

Service error console
Service error browser

有什么解决办法吗?谢谢

最佳答案

您是否具有所有计划的Pod的默认端点?我的意思是 ”/” ? Ingress内置运行状况检查就绪概率来检查“/”是否可达。如果不是,它将声明它不健康。
希望这可以帮助。

关于node.js - 使用Ingress服务类型将 “express-gateway”部署到Google Kubernetes Engine时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62139888/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com