Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save osadalakmal/3e94498886e0f4637054fecfccdb94ca to your computer and use it in GitHub Desktop.
Save osadalakmal/3e94498886e0f4637054fecfccdb94ca to your computer and use it in GitHub Desktop.
Consul Cluster with 6 containers.
version: '2'
networks:
consul_net:
driver: bridge
ipam:
driver: default
config:
-
subnet: 172.16.238.0/24
services:
consul_alpha:
image: "consul"
hostname: "consul_alpha"
command: "agent -disable-host-node-id --client 0.0.0.0 --server --data-dir /tmp/consul --bootstrap-expect 3 -raft-protocol 3"
networks:
consul_net:
ipv4_address: 172.16.238.10
ports:
- "8301:8300"
- "8401:8400"
- "8501:8500"
- "8601:8600"
- "9001:9001"
environment:
- CONSUL_OPTS=-bootstrap-expect=3
consul_bravo:
image: "consul"
hostname: "consul_bravo"
command: "agent -disable-host-node-id --client 0.0.0.0 --server --data-dir /tmp/consul --retry-join 172.16.238.10 --bootstrap-expect 3 -raft-protocol 3"
networks:
consul_net:
ipv4_address: 172.16.238.11
ports:
- "8302:8300"
- "8402:8400"
- "8502:8500"
- "8602:8600"
- "9002:9001"
consul_charlie:
image: "consul"
hostname: "consul_charlie"
command: "agent -disable-host-node-id --client 0.0.0.0 --server --data-dir /tmp/consul --retry-join 172.16.238.10 --bootstrap-expect 3 -raft-protocol 3"
networks:
consul_net:
ipv4_address: 172.16.238.12
ports:
- "8303:8300"
- "8403:8400"
- "8503:8500"
- "8603:8600"
- "9003:9001"
consul_delta:
image: "consul"
hostname: "consul_delta"
command: "agent -disable-host-node-id --client 0.0.0.0 --server --data-dir /tmp/consul --retry-join 172.16.238.10 --bootstrap-expect 3 -raft-protocol 3"
networks:
consul_net:
ipv4_address: 172.16.238.13
ports:
- "8304:8300"
- "8404:8400"
- "8504:8500"
- "8604:8600"
- "9004:9001"
consul_echo:
image: "consul"
hostname: "consul_echo"
command: "agent -disable-host-node-id --client 0.0.0.0 --server --data-dir /tmp/consul --retry-join 172.16.238.10 --bootstrap-expect 3 -raft-protocol 3"
networks:
consul_net:
ipv4_address: 172.16.238.14
ports:
- "8305:8300"
- "8405:8400"
- "8505:8500"
- "8605:8600"
- "9005:9001"
consul_foxtrot:
image: "consul"
hostname: "consul_foxtrot"
command: "agent -disable-host-node-id --client 0.0.0.0 --server --data-dir /tmp/consul --retry-join 172.16.238.10 --bootstrap-expect 3 -raft-protocol 3"
networks:
consul_net:
ipv4_address: 172.16.238.15
ports:
- "8306:8300"
- "8406:8400"
- "8506:8500"
- "8606:8600"
- "9006:9001"
vault_alpha:
depends_on:
- consul_alpha
- consul_bravo
- consul_charlie
image: "vault"
hostname: "vault_alpha"
networks:
consul_net:
ipv4_address: 172.16.238.21
environment:
VAULT_ADDR: http://172.16.238.21:8200
VAULT_CLUSTER_ADDR: https://172.16.238.21:8200
VAULT_REDIRECT_ADDR: http://172.16.238.21:8200
ports:
- "8201:8200"
volumes:
- ./tools/wait-for-it.sh:/wait-for-it.sh
- ./config/vault:/config
entrypoint: /wait-for-it.sh -t 40 -h consul_alpha -p 8500 -s -- vault server -config=/config/with-consul.hcl
vault_bravo:
depends_on:
- consul_alpha
- consul_bravo
- consul_charlie
image: "vault"
hostname: "vault_bravo"
networks:
consul_net:
ipv4_address: 172.16.238.22
environment:
VAULT_ADDR: http://172.16.238.22:8200
VAULT_CLUSTER_ADDR: https://172.16.238.22:8200
VAULT_REDIRECT_ADDR: http://172.16.238.22:8200
ports:
- "8202:8200"
volumes:
- ./tools/wait-for-it.sh:/wait-for-it.sh
- ./config/vault:/config
entrypoint: /wait-for-it.sh -t 40 -h consul_alpha -p 8500 -s -- vault server -config=/config/with-consul.hcl
vault_charlie:
depends_on:
- consul_alpha
- consul_bravo
- consul_charlie
image: "vault"
hostname: "vault_charlie"
networks:
consul_net:
ipv4_address: 172.16.238.23
environment:
VAULT_ADDR: http://172.16.238.23:8200
VAULT_CLUSTER_ADDR: https://172.16.238.23:8200
VAULT_REDIRECT_ADDR: http://172.16.238.23:8200
ports:
- "8203:8200"
volumes:
- ./tools/wait-for-it.sh:/wait-for-it.sh
- ./config/vault:/config
entrypoint: /wait-for-it.sh -t 40 -h consul_alpha -p 8500 -s -- vault server -config=/config/with-consul.hcl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment