[英]502 bad gateway using Kubernetes with Ingress controller
I have a Kubernetes setup on Minikube with this configuration:我在 Minikube 上使用以下配置进行了 Kubernetes 设置:
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: myappdeployment
spec:
replicas: 5
selector:
matchLabels:
app: myapp
template:
metadata:
labels:
app: myapp
spec:
containers:
- name: myapp
image: custom-docker-image:latest
ports:
- containerPort: 3000
---
kind: Service
apiVersion: v1
metadata:
name: example-service
spec:
selector:
app: myapp
ports:
- protocol: "TCP"
# Port accessible inside cluster
port: 3000
# Port to forward to inside the pod
targetPort: 3000
type: NodePort
---
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: example-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
- http:
paths:
- path: /
backend:
serviceName: example-service
servicePort: 3000
I took a look at the solution to this Stackoverflow post and it seems my configuration is.. fine?我查看了这篇 Stackoverflow 帖子的解决方案,看起来我的配置是......好吗?
What am I doing wrong to get 502 Bad Gateway when accessing http://192.xxx.xx.x , my Minikube address?访问http://192.xxx.xx.x 时,我的 Minikube 地址出现 502 Bad Gateway,我做错了什么? The
nginx-ingress-controller
logs say: nginx-ingress-controller
日志说:
...
Connection refused while connecting to upstream
...
Another odd piece of info, when I follow this guide to setting up the basic node service on Kubernetes, everything works and I see a "Hello world" page when I open up the Minikube add另一个奇怪的信息,当我按照本指南在 Kubernetes 上设置基本节点服务时,一切正常,当我打开 Minikube 添加时,我看到一个“Hello world”页面
Steps taken: I ran采取的步骤:我跑了
kubectl port-forward pods/myappdeployment-5dff57cfb4-6c6bd 3000:3000
Then I visited localhost:3000
and saw然后我访问了
localhost:3000
并看到
This page isn’t working
localhost didn’t send any data.
ERR_EMPTY_RESPONSE
I figured the reason is more obvious in the logs so I ran我认为原因在日志中更明显,所以我跑了
kubectl logs pods/myappdeployment-5dff57cfb4-6c6bd
and got并得到
Waiting for MySQL...
no destination
Waiting for MySQL...
no destination
Waiting for MySQL...
no destination
Waiting for MySQL...
no destination
...
Thus I reasoned that I was originally getting a 502 because all of the pods were not running due to no MySQL setup.因此,我推断我最初得到的是 502,因为由于没有设置 MySQL,所有 pod 都没有运行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.