Created
May 2, 2017 14:16
-
-
Save beldpro-ci/e7b6892f9211dd2d5e01d4a3fecf2641 to your computer and use it in GitHub Desktop.
3-server consul cluster with docker swarm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Using the latest docker-compose version as of 02/May/2017 so that | |
# we can leverage the `deploy` section with all of its properties. | |
# Using docker 17.05.0-ce-rc1 you should be able to deploy this without | |
# problems. | |
version: '3.2' | |
services: | |
# Declaring a consul-server service that is made up of 3 containers (replica=3) | |
# with endpoint-mode==dnsrr. This makes docker not create a virtual IP but just | |
# rely on dsn round-robin load-balancing. | |
consul: | |
image: 'consul:0.7.2' | |
command: | |
- 'agent' | |
- '-server' | |
- '-client=0.0.0.0' | |
- '-bind={{ GetInterfaceIP "eth0"}}' | |
- '-bootstrap-expect=3' | |
- '-retry-join=consul' | |
- '-retry-interval=5s' | |
- '-rejoin' | |
- '-ui' | |
networks: | |
infranet: | |
environment: | |
- 'CONSUL_LOCAL_CONFIG={"rejoin_after_leave": false, "leave_on_terminate": true}' | |
deploy: | |
replicas: 3 | |
restart_policy: | |
condition: 'on-failure' | |
mode: 'replicated' | |
endpoint_mode: 'dnsrr' | |
# Here you list all your networks. It's a map in the form of | |
# { "network_name": {network options}} | |
# where `infranet` is the name of the network with the options | |
# of `external: true` (explicitly saying that this is a network | |
# that has already been created outside of the scope of docker-compose. | |
# If we didn't specify `external:true` it'd try to create it. | |
networks: | |
infranet: | |
external: true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment