/consul-lab

Consul lab

Primary LanguageShell

consul-lab

Consul lab

lab1: "2 datacenters: single consul nodes on vm"

lab2: "2 datacenters: single consul nodes inside docker"

lab3: "2 datacenters: 3 nodes consul cluster in docker / single node inside docker"

join 2 datacenters

manually

/ # consul join -wan 10.0.0.4
Successfully joined cluster by contacting 1 nodes.

automatically using retry-join-wan

Add flag -retry-join-wan 10.0.0.4:8204 to consul agent in dc-1 or add

"retry-join-wan": "10.0.0.4:8204"

to json config file.

https://developer.hashicorp.com/consul/docs/agent/config/config-files#retry_join_wan https://developer.hashicorp.com/consul/docs/agent/config/cli-flags#_retry_join_wan

Important options:

Verify

  • check members
# consul members -wan
Node                  Address        Status  Type    Build   Protocol  DC       Partition  Segment
63b7c673db46.dc-1     10.0.0.5:8304  alive   server  1.18.0  2         dc-1     default    <all>
cd001120bb19.dc-main  10.0.0.4:8304  alive   server  1.18.0  2         dc-main  default    <all>
  • check consul members (specify http port of consul agent)
# consul members -wan -http-addr http://0.0.0.0:8500
Node                  Address        Status  Type    Build   Protocol  DC       Partition  Segment
63b7c673db46.dc-1     10.0.0.5:8304  alive   server  1.18.0  2         dc-1     default    <all>
cd001120bb19.dc-main  10.0.0.4:8304  alive   server  1.18.0  2         dc-main  default    <all>
  • check via /v1/catalog
curl http://localhost:8500/v1/catalog/datacenters
curl http://localhost:8500/v1/catalog/nodes?dc=dc-1
curl http://localhost:8500/v1/catalog/nodes?dc=dc-main

Docker images

https://hub.docker.com/r/hashicorp/consul-replicate https://hub.docker.com/r/hashicorp/consul

Links