我已经设置了k3s v1.20.4+k3s1与Klipper Lb和nginx入口3.24.0从舵表。我正在关注this article,但我偶然发现了一个非常奇怪的问题,我的入口主机会指向错误的服务。
下面是我的配置:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ingress-routing
spec:
rules:
- host: echo1.stage.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: echo1
port:
number: 80
- host: echo2.stage.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: echo2
port:
number: 80
---
apiVersion: v1
kind: Service
metadata:
name: echo1
spec:
ports:
- port: 80
targetPort: 5678
selector:
app: echo1
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: echo1
spec:
selector:
matchLabels:
app: echo1
replicas: 2
template:
metadata:
labels:
app: echo1
spec:
containers:
- name: echo1
image: hashicorp/http-echo
args:
- "-text=This is echo1"
ports:
- containerPort: 5678
---
apiVersion: v1
kind: Service
metadata:
name: echo2
spec:
ports:
- port: 80
targetPort: 5678
selector:
app: echo2
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: echo2
spec:
selector:
matchLabels:
app: echo2
replicas: 1
template:
metadata:
labels:
app: echo2
spec:
containers:
- name: echo2
image: hashicorp/http-echo
args:
- "-text=This is the new (echo2)"
ports:
- containerPort: 5678和我的Cloudflare DNS记录(未激活DNS代理):
;; A Records
api.stage.example.com. 1 IN A 162.15.166.240
echo1.stage.example.com. 1 IN A 162.15.166.240
echo2.stage.example.com. 1 IN A 162.15.166.240但是当我在echo1.stage.example.com上做多次卷曲时,我得到的结果如下:
$ curl echo1.stage.example.com
This is echo1
$ curl echo1.stage.example.com
<html>
<head><title>502 Bad Gateway</title></head>
<body>
<center><h1>502 Bad Gateway</h1></center>
<hr><center>nginx</center>
</body>
</html>
$ curl echo1.stage.example.com
This is the new (echo2)有时我得到一个糟糕的网关,有时我得到指向分配给echo2.stage.example.com的服务的echo1.stage.example.com域。这是因为LB吗?或者是我这一端的配置不好?谢谢!
编辑:这不是来自LB,我刚刚切换到metallb,我仍然得到同样的问题
发布于 2021-03-20 20:49:38
好了,我找到问题所在了。它实际上与我之前发布到我的kustomization.yaml配置中的配置无关,在那里我有:
commonLabels:
app: myapp移除该commonLabels就解决了这个问题。
https://stackoverflow.com/questions/66720408
复制相似问题