Skip to content

Instantly share code, notes, and snippets.

@ilosamart
Last active May 4, 2017 16:06
Show Gist options
  • Save ilosamart/c4c0dbde42e82965ae5342c695e9dd2b to your computer and use it in GitHub Desktop.
Save ilosamart/c4c0dbde42e82965ae5342c695e9dd2b to your computer and use it in GitHub Desktop.
version: '2'
#client local machine:
# consul agent -bind=172.18.233.1 -client=0.0.0.0 -retry-join=172.18.233.20 -data-dir /tmp/data -ui -recursor=127.0.1.1
#client dns config:
# iptables -t nat -I PREROUTING -p udp -m udp --dport 53 -j REDIRECT --to-ports 8600
# iptables -t nat -I PREROUTING -p tcp -m tcp --dport 53 -j REDIRECT --to-ports 8600
# iptables -t nat -I OUTPUT -d localhost -p udp -m udp --dport 53 -j REDIRECT --to-ports 8600
# iptables -t nat -I OUTPUT -d localhost -p tcp -m tcp --dport 53 -j REDIRECT --to-ports 8600
services:
consul1:
hostname: consul1
image: consul
environment:
CONSUL_LOCAL_CONFIG: "{\"skip_leave_on_interrupt\": true, \"leave_on_terminate\": false }"
dns: 172.18.233.1
command: consul agent -server -ui -client=0.0.0.0 -bind=0.0.0.0 -retry-join=consul1 -bootstrap-expect=3 -data-dir=/consul/data
networks:
app_net:
ipv4_address: 172.18.233.20
expose:
- "8301"
- "8301/udp"
- "8302"
- "8302/udp"
- "8400"
- "8500"
- "8600"
- "8600/udp"
consul2:
hostname: consul2
image: consul
environment:
CONSUL_LOCAL_CONFIG: "{\"skip_leave_on_interrupt\": true, \"leave_on_terminate\": false }"
dns: 172.18.233.1
command: consul agent -server -ui -client=0.0.0.0 -bind=0.0.0.0 -retry-join=consul1 -bootstrap-expect=3 -data-dir=/consul/data
networks:
app_net:
ipv4_address: 172.18.233.21
expose:
- "8301"
- "8301/udp"
- "8302"
- "8302/udp"
- "8400"
- "8500"
- "8600"
- "8600/udp"
consul3:
hostname: consul3
image: consul
environment:
CONSUL_LOCAL_CONFIG: "{\"skip_leave_on_interrupt\": true, \"leave_on_terminate\": false }"
dns: 172.18.233.1
command: consul agent -server -ui -client=0.0.0.0 -bind=0.0.0.0 -retry-join=consul1 -bootstrap-expect=3 -data-dir=/consul/data
networks:
app_net:
ipv4_address: 172.18.233.22
expose:
- "8301"
- "8301/udp"
- "8302"
- "8302/udp"
- "8400"
- "8500"
- "8600"
- "8600/udp"
app1:
hostname: app1
image: tramasoli/sample-springboot-rest
networks:
- app_net
app2:
hostname: app2
image: tramasoli/sample-springboot-rest
networks:
- app_net
networks:
app_net:
driver: bridge
ipam:
driver: default
config:
- subnet: 172.18.233.0/24
gateway: 172.18.233.1
ip_range: 172.18.233.64/26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment