kubertes入口返回502



我的Kubernetes入口有一些问题,只有这个服务总是返回502。我已经测试了这个服务,它工作得很好,但是当我用入口暴露它时,它不工作。

我使用EKS和Nginx入口控制器

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
namespace: develop
name: chatbot-ingress
annotations:
kubernetes.io/ingress.class: "nginx"
spec:
rules:
- http:
paths:
- backend:
service:
name: chatbot
port:
number: 7070
pathType: Prefix
path: /
host: api.example.com
---
apiVersion: v1
kind: Service
metadata:
name: chatbot
namespace: develop
spec:
selector:
app: chatbot
ports:
- port: 7070
targetPort: 7070
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: chatbot
namespace: develop
spec:
selector:
matchLabels:
app: chatbot
template:
metadata:
labels:
app: chatbot
spec:
containers:
- name: chatbot
image: chatbot 
imagePullPolicy: Always
envFrom:
- secretRef:
name: chatbot-secret
ports:
- containerPort: 7070

进入日志

2022/06/16 13:51:20 [error] 2069#2069: *9278411 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.49.139, server: api.example.com, request: "GET / HTTP/2.0", upstream: "http://192.168.8.148:7070/", host: "api.example.com"
2022/06/16 13:51:20 [error] 2069#2069: *9278411 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.49.139, server: api.example.com, request: "GET / HTTP/2.0", upstream: "http://192.168.8.148:7070/", host: "api.example.com"

主机是否应该从api.example.com更新为要连接的服务的相关端点?

spec:
rules:
- http:
paths:
- backend:
service:
name: chatbot
port:
number: 7070
pathType: Prefix
path: /
host: api.example.com

使用像Lumigo这样的服务来做一些跟踪可能会有所帮助(他们有一个免费的层)

结果是我运行的图像暴露在localhost:7070而不是0.0.0.0:7070上。然而,我仍然不知道为什么我的服务能够连接到pod,我可以通过端口转发测试它,但我的入口无法连接到工作的服务。