node1:
docker stop consul-node1 docker rm -f consul-node1 docker run –name=consul-node1 –restart=always -d \ –net=host \ -e CONSUL_BIND_INTERFACE=eth0 \ -v /data/consul-node1/config:/consul/config \ -v /data/consul-node1/data:/consul/data \ consul:1.6.1 agent \ -server \ -bootstrap-expect=3 \ -bind=0.0.0.0 \ -join=10.10.168.6 \ -join=10.10.94.142 \ -join=10.10.38.118 \ -advertise=10.10.168.6 \ -data-dir=/consul/data \ -client 0.0.0.0 -ui
node2:
docker stop consul-node2 docker rm -f consul-node2 docker run –name=consul-node2 –restart=always -d \ –net=host \ -e CONSUL_BIND_INTERFACE=eth0 \ -v /data/consul-node2/config:/consul/config \ -v /data/consul-node2/data:/consul/data \ consul:1.6.1 agent \ -server \ -bootstrap-expect=3 \ -bind=0.0.0.0 \ -advertise=10.10.94.142 \ -join=10.10.168.6 \ -join=10.10.94.142 \ -join=10.10.38.118 \ -data-dir=/consul/data \ -client 0.0.0.0 -ui
node3:
docker stop consul-node3 docker rm -f consul-node3 docker run –name=consul-node3 –restart=always -d \ –net=host \ -e CONSUL_BIND_INTERFACE=eth0 \ -v /data/consul-node3/config:/consul/config \ -v /data/consul-node3/data:/consul/data \ consul:1.6.1 agent \ -server \ -bootstrap-expect=3 \ -bind=0.0.0.0 \ -advertise=10.10.38.118 \ -join=10.10.168.6 \ -join=10.10.94.142 \ -join=10.10.38.118 \ -data-dir=/consul/data \ -client 0.0.0.0 -ui
client node
docker rm -f consul-client
docker run –name=consul-client -d –restart=always \ -e ‘CONSUL_LOCAL_CONFIG={“leave_on_terminate”: true}’ \ -e CONSUL_BIND_INTERFACE=eth0 \ –net=host \ -v /data/consul-client/config:/consul/config \ -v /data/consul-client/data:/consul/data \ consul agent \ -client \ -bind=0.0.0.0 \ -join=10.10.168.6 \ -join=10.10.94.142 \ -join=10.10.38.118 \ -data-dir=/consul/data \ -node-id=$(uuidgen | awk ‘{print tolower($0)}’) \ -client 0.0.0.0 -ui
watch_service.json
{
"watches": [
{
"type": "services",
"handler_type": "http",
"http_handler_config": {
"path": "http://192.168.13.192:8080/services",
"method": "POST"
}
},
{
"type": "nodes",
"handler_type": "http",
"http_handler_config": {
"path": "http://192.168.13.192:8080/nodes",
"method": "POST"
}
},
{
"type": "checks",
"handler_type": "http",
"http_handler_config": {
"path": "http://192.168.13.192:8080/checks",
"method": "POST"
}
}
]
}