updated
This commit is contained in:
76
swarm/stacks/consul-cluster-fixed.yml
Normal file
76
swarm/stacks/consul-cluster-fixed.yml
Normal file
@@ -0,0 +1,76 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
consul-master:
|
||||
image: consul:latest
|
||||
hostname: consul-master
|
||||
command: >
|
||||
sh -c "
|
||||
IP=$$(hostname -i | awk '{print $$1}');
|
||||
consul agent -server -bootstrap-expect=2
|
||||
-datacenter=dc1 -data-dir=/consul/data
|
||||
-node=consul-master -bind=$$IP -advertise=$$IP -client=0.0.0.0
|
||||
-ui
|
||||
-log-level=INFO
|
||||
"
|
||||
ports:
|
||||
- "8500:8500"
|
||||
- "8600:8600/udp"
|
||||
volumes:
|
||||
- consul_master_data:/consul/data
|
||||
networks:
|
||||
consul-net:
|
||||
aliases:
|
||||
- consul-master
|
||||
deploy:
|
||||
mode: replicated
|
||||
replicas: 1
|
||||
placement:
|
||||
constraints:
|
||||
- node.hostname == master
|
||||
restart_policy:
|
||||
condition: on-failure
|
||||
delay: 5s
|
||||
max_attempts: 3
|
||||
|
||||
consul-ash3c:
|
||||
image: consul:latest
|
||||
hostname: consul-ash3c
|
||||
command: >
|
||||
sh -c "
|
||||
IP=$$(hostname -i | awk '{print $$1}');
|
||||
consul agent -server -bootstrap-expect=2
|
||||
-datacenter=dc1 -data-dir=/consul/data
|
||||
-node=consul-ash3c -bind=$$IP -advertise=$$IP -client=0.0.0.0
|
||||
-retry-join=consul-master
|
||||
-ui
|
||||
-log-level=INFO
|
||||
"
|
||||
ports:
|
||||
- "8501:8500"
|
||||
- "8601:8600/udp"
|
||||
volumes:
|
||||
- consul_ash3c_data:/consul/data
|
||||
networks:
|
||||
consul-net:
|
||||
aliases:
|
||||
- consul-ash3c
|
||||
deploy:
|
||||
mode: replicated
|
||||
replicas: 1
|
||||
placement:
|
||||
constraints:
|
||||
- node.hostname == ash3c
|
||||
restart_policy:
|
||||
condition: on-failure
|
||||
delay: 5s
|
||||
max_attempts: 3
|
||||
|
||||
volumes:
|
||||
consul_master_data:
|
||||
consul_ash3c_data:
|
||||
|
||||
networks:
|
||||
consul-net:
|
||||
driver: overlay
|
||||
attachable: true
|
||||
68
swarm/stacks/consul-cluster-host-network.yml
Normal file
68
swarm/stacks/consul-cluster-host-network.yml
Normal file
@@ -0,0 +1,68 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
consul-master:
|
||||
image: consul:latest
|
||||
hostname: consul-master
|
||||
command: >
|
||||
sh -c "
|
||||
consul agent -server -bootstrap-expect=2
|
||||
-datacenter=dc1 -data-dir=/consul/data
|
||||
-node=consul-master -bind=100.117.106.136 -advertise=100.117.106.136 -client=0.0.0.0
|
||||
-ui
|
||||
-log-level=INFO
|
||||
"
|
||||
ports:
|
||||
- "8500:8500"
|
||||
- "8600:8600/udp"
|
||||
- "8301:8301"
|
||||
- "8302:8302"
|
||||
volumes:
|
||||
- consul_master_data:/consul/data
|
||||
deploy:
|
||||
mode: replicated
|
||||
replicas: 1
|
||||
placement:
|
||||
constraints:
|
||||
- node.hostname == master
|
||||
restart_policy:
|
||||
condition: on-failure
|
||||
delay: 5s
|
||||
max_attempts: 3
|
||||
|
||||
consul-ash3c:
|
||||
image: consul:latest
|
||||
hostname: consul-ash3c
|
||||
command: >
|
||||
sh -c "
|
||||
ASH3C_IP=$$(getent hosts ash3c | awk '{print $$1}');
|
||||
consul agent -server -bootstrap-expect=2
|
||||
-datacenter=dc1 -data-dir=/consul/data
|
||||
-node=consul-ash3c -bind=$$ASH3C_IP -advertise=$$ASH3C_IP -client=0.0.0.0
|
||||
-retry-join=100.117.106.136
|
||||
-ui
|
||||
-log-level=INFO
|
||||
"
|
||||
ports:
|
||||
- "8501:8500"
|
||||
- "8601:8600/udp"
|
||||
- "8311:8301"
|
||||
- "8312:8302"
|
||||
volumes:
|
||||
- consul_ash3c_data:/consul/data
|
||||
deploy:
|
||||
mode: replicated
|
||||
replicas: 1
|
||||
placement:
|
||||
constraints:
|
||||
- node.hostname == ash3c
|
||||
restart_policy:
|
||||
condition: on-failure
|
||||
delay: 5s
|
||||
max_attempts: 3
|
||||
depends_on:
|
||||
- consul-master
|
||||
|
||||
volumes:
|
||||
consul_master_data:
|
||||
consul_ash3c_data:
|
||||
78
swarm/stacks/consul-cluster-ip-based.yml
Normal file
78
swarm/stacks/consul-cluster-ip-based.yml
Normal file
@@ -0,0 +1,78 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
consul-master:
|
||||
image: consul:latest
|
||||
hostname: consul-master
|
||||
command: >
|
||||
sh -c "
|
||||
IP=$$(hostname -i | awk '{print $$1}');
|
||||
consul agent -server -bootstrap-expect=2
|
||||
-datacenter=dc1 -data-dir=/consul/data
|
||||
-node=consul-master -bind=$$IP -advertise=$$IP -client=0.0.0.0
|
||||
-ui
|
||||
-log-level=INFO
|
||||
"
|
||||
ports:
|
||||
- "8500:8500"
|
||||
- "8600:8600/udp"
|
||||
volumes:
|
||||
- consul_master_data:/consul/data
|
||||
networks:
|
||||
consul-net:
|
||||
aliases:
|
||||
- consul-master
|
||||
deploy:
|
||||
mode: replicated
|
||||
replicas: 1
|
||||
placement:
|
||||
constraints:
|
||||
- node.hostname == master
|
||||
restart_policy:
|
||||
condition: on-failure
|
||||
delay: 5s
|
||||
max_attempts: 3
|
||||
|
||||
consul-ash3c:
|
||||
image: consul:latest
|
||||
hostname: consul-ash3c
|
||||
command: >
|
||||
sh -c "
|
||||
IP=$$(hostname -i | awk '{print $$1}');
|
||||
consul agent -server -bootstrap-expect=2
|
||||
-datacenter=dc1 -data-dir=/consul/data
|
||||
-node=consul-ash3c -bind=$$IP -advertise=$$IP -client=0.0.0.0
|
||||
-retry-join=10.0.5.5
|
||||
-ui
|
||||
-log-level=INFO
|
||||
"
|
||||
ports:
|
||||
- "8501:8500"
|
||||
- "8601:8600/udp"
|
||||
volumes:
|
||||
- consul_ash3c_data:/consul/data
|
||||
networks:
|
||||
consul-net:
|
||||
aliases:
|
||||
- consul-ash3c
|
||||
deploy:
|
||||
mode: replicated
|
||||
replicas: 1
|
||||
placement:
|
||||
constraints:
|
||||
- node.hostname == ash3c
|
||||
restart_policy:
|
||||
condition: on-failure
|
||||
delay: 5s
|
||||
max_attempts: 3
|
||||
depends_on:
|
||||
- consul-master
|
||||
|
||||
volumes:
|
||||
consul_master_data:
|
||||
consul_ash3c_data:
|
||||
|
||||
networks:
|
||||
consul-net:
|
||||
driver: overlay
|
||||
attachable: true
|
||||
78
swarm/stacks/consul-cluster-macvlan.yml
Normal file
78
swarm/stacks/consul-cluster-macvlan.yml
Normal file
@@ -0,0 +1,78 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
consul-master:
|
||||
image: consul:latest
|
||||
hostname: consul-master
|
||||
command: >
|
||||
sh -c "
|
||||
consul agent -server -bootstrap-expect=2
|
||||
-datacenter=dc1 -data-dir=/consul/data
|
||||
-node=consul-master -bind=192.168.1.100 -advertise=192.168.1.100 -client=0.0.0.0
|
||||
-ui
|
||||
-log-level=INFO
|
||||
"
|
||||
ports:
|
||||
- "8500:8500"
|
||||
- "8600:8600/udp"
|
||||
volumes:
|
||||
- consul_master_data:/consul/data
|
||||
networks:
|
||||
consul-macvlan:
|
||||
ipv4_address: 192.168.1.100
|
||||
deploy:
|
||||
mode: replicated
|
||||
replicas: 1
|
||||
placement:
|
||||
constraints:
|
||||
- node.hostname == master
|
||||
restart_policy:
|
||||
condition: on-failure
|
||||
delay: 5s
|
||||
max_attempts: 3
|
||||
|
||||
consul-ash3c:
|
||||
image: consul:latest
|
||||
hostname: consul-ash3c
|
||||
command: >
|
||||
sh -c "
|
||||
consul agent -server -bootstrap-expect=2
|
||||
-datacenter=dc1 -data-dir=/consul/data
|
||||
-node=consul-ash3c -bind=192.168.1.101 -advertise=192.168.1.101 -client=0.0.0.0
|
||||
-retry-join=192.168.1.100
|
||||
-ui
|
||||
-log-level=INFO
|
||||
"
|
||||
ports:
|
||||
- "8501:8500"
|
||||
- "8601:8600/udp"
|
||||
volumes:
|
||||
- consul_ash3c_data:/consul/data
|
||||
networks:
|
||||
consul-macvlan:
|
||||
ipv4_address: 192.168.1.101
|
||||
deploy:
|
||||
mode: replicated
|
||||
replicas: 1
|
||||
placement:
|
||||
constraints:
|
||||
- node.hostname == ash3c
|
||||
restart_policy:
|
||||
condition: on-failure
|
||||
delay: 5s
|
||||
max_attempts: 3
|
||||
|
||||
volumes:
|
||||
consul_master_data:
|
||||
consul_ash3c_data:
|
||||
|
||||
networks:
|
||||
consul-macvlan:
|
||||
driver: macvlan
|
||||
driver_opts:
|
||||
parent: eth0 # 根据你的网络接口调整
|
||||
ipam:
|
||||
config:
|
||||
- subnet: 192.168.1.0/24
|
||||
gateway: 192.168.1.1
|
||||
ip_range: 192.168.1.100/30 # 只分配 .100-.103 的IP
|
||||
40
swarm/stacks/consul-single-node.yml
Normal file
40
swarm/stacks/consul-single-node.yml
Normal file
@@ -0,0 +1,40 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
consul:
|
||||
image: consul:latest
|
||||
hostname: consul-master
|
||||
command: >
|
||||
sh -c "
|
||||
IP=$$(hostname -i | awk '{print $$1}');
|
||||
consul agent -server -bootstrap-expect=1
|
||||
-datacenter=dc1 -data-dir=/consul/data
|
||||
-node=consul-master -bind=$$IP -advertise=$$IP -client=0.0.0.0
|
||||
-ui
|
||||
-log-level=INFO
|
||||
"
|
||||
ports:
|
||||
- "8500:8500"
|
||||
- "8600:8600/udp"
|
||||
volumes:
|
||||
- consul_data:/consul/data
|
||||
networks:
|
||||
- consul-net
|
||||
deploy:
|
||||
mode: replicated
|
||||
replicas: 1
|
||||
placement:
|
||||
constraints:
|
||||
- node.hostname == master
|
||||
restart_policy:
|
||||
condition: on-failure
|
||||
delay: 5s
|
||||
max_attempts: 3
|
||||
|
||||
volumes:
|
||||
consul_data:
|
||||
|
||||
networks:
|
||||
consul-net:
|
||||
driver: overlay
|
||||
attachable: true
|
||||
Reference in New Issue
Block a user