我正在尝试构建 Consul 集群堆栈。我当前的配置工作正常,但是在重新启动领事领导或全栈后,集群在投票给新领导时出现问题。
服务重新启动后,新任务对于相同的节点 ID 具有不同的 IP 地址。
领事代理配置是否有任何参数可以修复集群中的地址更改?
在我当前的堆栈定义之下
version: '3.5'
services:
consulLeader:
image: consul
volumes:
- consul_l_data:/consul/data
command: 'agent -bind "{{ GetInterfaceIP \"eth0\" }}" -bootstrap-expect 3 -client 0.0.0.0 -ui -server -node nodeLeader -retry-join consulNode1 -retry-join consulNode2'
environment:
- "CONSUL_LOCAL_CONFIG={\"skip_leave_on_interrupt\": true,\"leave_on_terminate\": true}"
consulNode1:
image: consul
volumes:
- consul_n1_data:/consul/data
command: 'agent -bind "{{ GetInterfaceIP \"eth0\" }}" -disable-host-node-id -client 0.0.0.0 -ui -server -node consulNode1 -retry-join consulLeader -retry-join consulNode2'
environment:
- "CONSUL_LOCAL_CONFIG={\"skip_leave_on_interrupt\": true,\"leave_on_terminate\": true}"
consulNode2:
image: consul
volumes:
- consul_n2_data:/consul/data
command: 'agent -bind "{{ GetInterfaceIP \"eth0\" }}" -disable-host-node-id -client 0.0.0.0 -ui -server -node consulNode2 -retry-join consulLeader -retry-join consulNode1'
environment:
- "CONSUL_LOCAL_CONFIG={\"skip_leave_on_interrupt\": true,\"leave_on_terminate\": true}"
# loadballancer
nginxForCluster:
image: nginx
deploy:
replicas: 1
placement:
constraints:
- node.role == manager
configs:
- source: consul_nginx.conf
target: /etc/nginx/nginx.conf
mode: 0440
ports:
- 8080:80
configs:
consul_nginx.conf:
external: true
volumes:
consul_l_data:
consul_n1_data:
consul_n2_data: