Skip to content

Instantly share code, notes, and snippets.

@benjamin658
Last active November 1, 2017 08:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save benjamin658/6eac792c3ec95464b9c14d6372128e9c to your computer and use it in GitHub Desktop.
Save benjamin658/6eac792c3ec95464b9c14d6372128e9c to your computer and use it in GitHub Desktop.
Setting up a consul cluster and registrator on Rancher.
version: '2'
services:
consul-lb:
image: rancher/lb-service-haproxy:v0.7.8
ports:
- 8400
- 8500
- 8600
expose:
- 8400
- 8500
- 8600
environment:
- SERVICE_8500_NAME=consul-admin
labels:
io.rancher.container.network: true
consul-1:
command: "-server -bootstrap-expect 3 -ui-dir /ui"
image: progrium/consul:latest
ports:
- 8400
- 8500
- 8600
environment:
- SERVICE_8300_IGNORE=yes
- SERVICE_8301_IGNORE=yes
- SERVICE_8302_IGNORE=yes
- SERVICE_8400_IGNORE=yes
- SERVICE_8600_IGNORE=yes
labels:
io.rancher.container.network: true
io.rancher.container.hostname_override: container_name
consul: 'true'
consul-2:
command: "-server -join consul-1"
image: progrium/consul:latest
ports:
- 8400
- 8500
- 8600
depends_on:
- consul-1
environment:
- SERVICE_8300_IGNORE=yes
- SERVICE_8301_IGNORE=yes
- SERVICE_8302_IGNORE=yes
- SERVICE_8400_IGNORE=yes
- SERVICE_8600_IGNORE=yes
labels:
io.rancher.container.network: true
io.rancher.container.hostname_override: container_name
consul: true
consul-3:
command: "-server -join consul-1"
image: progrium/consul:latest
ports:
- 8400
- 8500
- 8600
depends_on:
- consul-1
environment:
- SERVICE_8300_IGNORE=yes
- SERVICE_8301_IGNORE=yes
- SERVICE_8302_IGNORE=yes
- SERVICE_8400_IGNORE=yes
- SERVICE_8600_IGNORE=yes
labels:
io.rancher.container.network: true
io.rancher.container.hostname_override: container_name
consul: true
registrator:
image: gliderlabs/registrator:master
volumes:
- /var/run/docker.sock:/tmp/docker.sock
depends_on:
- consul-lb
command:
- -internal
- -useIpFromLabel
- io.rancher.container.ip
- consul://consul-lb:8500
labels:
io.rancher.container.network: true
io.rancher.container.hostname_override: container_name
io.rancher.scheduler.global: 'true'
version: '2'
services:
consul-1:
scale: 1
start_on_create: true
consul-2:
scale: 1
start_on_create: true
consul-3:
scale: 1
start_on_create: true
registrator:
start_on_create: true
consul-lb:
scale: 1
start_on_create: true
lb_config:
certs: []
port_rules:
- priority: 1
protocol: tcp
selector: consul=true
source_port: 8400
target_port: 8400
- priority: 1
protocol: tcp
selector: consul=true
source_port: 8500
target_port: 8500
- priority: 1
protocol: tcp
selector: consul=true
source_port: 8600
target_port: 8600
health_check:
response_timeout: 2000
healthy_threshold: 2
port: 42
unhealthy_threshold: 3
initializing_timeout: 60000
interval: 2000
reinitializing_timeout: 60000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment