我有一个库伯内特斯设置在Minikube与此配置:
---
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
我看了一下这个Stackoverflow帖子的解决方案,似乎我的配置是…好吗?
当访问我的Minikube地址http://192.xxx. xx.x时,我做错了什么来获取502错误网关?nginx-ingress-控制器
日志说:
...
Connection refused while connecting to upstream
...
另一个奇怪的信息,当我按照这个指南在库伯内特斯上设置基本节点服务时,一切正常,当我打开Minikube添加时,我看到一个“Hello world”页面
采取的步骤:我跑了
kubectl port-forward pods/myappdeployment-5dff57cfb4-6c6bd 3000:3000
然后我访问了localhost:3000
看到
This page isn’t working
localhost didn’t send any data.
ERR_EMPTY_RESPONSE
我想原因在日志上更明显所以我跑了
kubectl logs pods/myappdeployment-5dff57cfb4-6c6bd
并得到了
Waiting for MySQL...
no destination
Waiting for MySQL...
no destination
Waiting for MySQL...
no destination
Waiting for MySQL...
no destination
...
因此,我推断我最初得到的是502,因为由于没有MySQL设置,所有pod都没有运行。