首页 新闻 会员 周边 捐助

k8s上部署consul集群

0
悬赏园豆:50 [已关闭问题] 关闭于 2021-04-16 09:41

我在k8s上部署consul集群,StatefulSet有三个replias。三个pod状态正常,但就是加入不了consul集群,consul集群总是只有一个成员。手动join提示connect refused。

我的服务配置:

apiVersion: apps/v1
kind: StatefulSet
metadata:
name: consul
spec:
selector:
matchLabels:
app: consul
serviceName: consul
replicas: 3
template:
metadata:
labels:
app: consul
spec:
terminationGracePeriodSeconds: 10
containers:
- name: consul
image: consul:latest
args:
- "agent"
- "-server"
- "-bootstrap-expect=3"
- "-ui"
- "-data-dir=/consul/data"
- "-bind=0.0.0.0"
- "-client=0.0.0.0"
- "-advertise=$(PODIP)"
- "-retry-join=consul-0.consul.$(NAMESPACE).svc.cluster.local"
- "-retry-join=consul-1.consul.$(NAMESPACE).svc.cluster.local"
- "-retry-join=consul-2.consul.$(NAMESPACE).svc.cluster.local"
- "-domain=cluster.local"
- "-disable-host-node-id"
volumeMounts:
- name: data
mountPath: /consul/data
env:
- name: PODIP
valueFrom:
fieldRef:
fieldPath: status.podIP
- name: NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
ports:
- containerPort: 8500
name: ui-port
- containerPort: 8400
name: alt-port
- containerPort: 53
name: udp-port
- containerPort: 8443
name: https-port
- containerPort: 8080
name: http-port
- containerPort: 8301
name: serflan
- containerPort: 8302
name: serfwan
- containerPort: 8600
name: consuldns
- containerPort: 8300
name: server
volumes:
- name: data
hostPath:
path: /home/data

Pod状态
[root@kingsundevserver1 ~]# kubectl get pods -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
consul-0 1/1 Running 0 88m 10.100.146.173 kingsundocker <none> <none>
consul-1 1/1 Running 0 88m 10.100.146.172 kingsundocker <none> <none>
consul-2 1/1 Running 0 88m 10.100.146.169 kingsundocker <none> <none>

command terminated with exit code 127
[root@kingsundevserver1 ~]# kubectl exec consul-0 consul members
Error retrieving members: Get http://127.0.0.1:8500/v1/agent/members?segment=_all: dial tcp 127.0.0.1:8500: connect: connection refused
command terminated with exit code 1
[root@kingsundevserver1 ~]# kubectl exec consul-1 consul members
Node Address Status Type Build Protocol DC Segment
consul-1 10.100.146.172:8301 alive server 1.6.2 2 dc1 <all>
[root@kingsundevserver1 ~]# kubectl exec consul-2 consul members
Error retrieving members: Get http://127.0.0.1:8500/v1/agent/members?segment=_all: dial tcp 127.0.0.1:8500: connect: connection refused
command terminated with exit code 1
[root@kingsundevserver1 ~]#

坚持坚持的主页 坚持坚持 | 菜鸟二级 | 园豆:202
提问于:2019-12-02 12:08
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册