Hi everybody,
I would like to configure my consul client to use an “auto-discovered consul server”. In the doc most of the examples show a config with: “retry_join”:[ “192.168.1.1”] but I would like to avoid hard-coding ip or name.
To try to do this:
- I’ve installed avahi and consul on a linux machine.
- I’ve defined an avahi service on this machine using this config file:
sudo nano /etc/avahi/services/evs-hwfw-consul-server.service
> <?xml version="1.0" standalone='no'?>
> <!DOCTYPE service-group SYSTEM "avahi-service.dtd">
> <service-group>
> <name replace-wildcards="yes">Xts Consul Server on %h</name>
> <service>
> <type>_evs-hwfw-xts-consul-server._tcp</type>
> <port>8300</port>
> </service>
> </service-group>
- I can see my service using avahi-browse on that linux machine or from another linux pc in the same Lan
- I launch my consul server on this machine and all is ok from consul side.
After that, I
- I install consul on another linux machine
- I launch it as a client with the following config:
{
“advertise_addr”: “10.129.170.14”,
“bind_addr”: “10.129.170.14”,
“bootstrap_expect”: 1,
“client_addr”: “0.0.0.0”,
“datacenter”: “bha_dc”,
“data_dir”: “/home/bha/grafana/consul/data”,
“domain”: “consul”,
“enable_script_checks”: true,
“dns_config”: {
“enable_truncate”: true,
“only_passing”: true
},
“enable_syslog”: false,
“encrypt”: “”,
“leave_on_terminate”: true,
“log_level”: “DEBUG”,
“rejoin_after_leave”: true,
“retry_join”: [
“provider=mdns”,
“service=_evs-hwfw-xts-consul-server._tcp.local”
],
“server”: true,
“ui_config”: {
“enabled”: true
}
}
When i launch consul i can see in the log:
2024-06-21T15:15:30.172+0200 [INFO] agent: Retry join is supported for the following discovery methods: cluster=LAN discovery_methods=“aliyun aws azure digitalocean gce hcp k8s linode mdns os packet scaleway softlayer tencentcloud triton vsphere”
2024-06-21T15:15:30.172+0200 [INFO] agent: Joining cluster…: cluster=LAN
2024-06-21T15:15:30.172+0200 [DEBUG] agent: discover: Using provider “mdns”: cluster=LAN
2024-06-21T15:15:30.172+0200 [WARN] agent.router.manager: No servers available
2024-06-21T15:15:30.172+0200 [ERROR] agent.anti_entropy: failed to sync remote state: error=“No known Consul servers”
2024-06-21T15:15:30.172+0200 [ERROR] agent: Cannot discover address: cluster=LAN address=provider=mdns error="discover-mdns: Service record not provided. Please specify a service record for the mDNS lookup."
2024-06-21T15:15:30.172+0200 [INFO] agent: (LAN) joining: lan_addresses=[“service=_evs-hwfw-xts-consul-server._tcp.local”]
2024-06-21T15:15:30.192+0200 [WARN] agent.client.memberlist.lan: memberlist: Failed to resolve service=_evs-hwfw-xts-consul-server._tcp.local: lookup service=_evs-hwfw-xts-consul-server._tcp.local: no such host
2024-06-21T15:15:30.192+0200 [WARN] agent: (LAN) couldn’t join: number_of_nodes=0
error=
| 1 error occurred:
| \t* Failed to resolve service=_evs-hwfw-xts-consul-server._tcp.local: lookup service=_evs-hwfw-xts-consul-server._tcp.local: no such host
|
2024-06-21T15:15:30.192+0200 [WARN] agent: Join cluster failed, will retry: cluster=LAN retry_interval=30s
error=
| 1 error occurred:
| \t* Failed to resolve service=_evs-hwfw-xts-consul-server._tcp.local: lookup service=_evs-hwfw-xts-consul-server._tcp.local: no such host
|
If i type avahi-browse -rt _evs-hwfw-xts-consul-server._tcp on this machine:
- enp1s0f0 IPv6 Xts Consul Server on fw-xta2 _evs-hwfw-xts-consul-server._tcp local
- enp1s0f0 IPv4 Xts Consul Server on fw-xta2 _evs-hwfw-xts-consul-server._tcp local
= enp1s0f0 IPv6 Xts Consul Server on fw-xta2 _evs-hwfw-xts-consul-server._tcp local
hostname = [fw-xta2.local]
address = [fe80::ec4:7aff:fe57:9238]
port = [8300]
txt =
= enp1s0f0 IPv4 Xts Consul Server on fw-xta2 _evs-hwfw-xts-consul-server._tcp local
hostname = [fw-xta2.local]
address = [10.129.170.14]
port = [8300]
txt =
i can see the _evs-hwfw-xts-consul-server._tcp service, so i a little bit lost/disappointed :-):
Why consul is not able to see/use my mdns avahi service ?
- Am i missing something ?
- Is what i try to do is possible with consul/avahi ?
- Is it a better way to do this ?
Any ideas, suggestions and/or comments are welcome
Best regards