Search code examples
consul

Consul node will not be discoverable via DNS due to invalid characters


We are primarily a VM based environment with a lot of microservices that need client discovery, configuration management etc. So decided to use Hashicorp Consul.

we are facing an issue: hostname with the dot(.)

[WARN] agent: Node name "myorg.vsi.uat.xxx.com" will not be discoverable via DNS due to invalid characters. Valid characters include all alpha-numerics and dashes.

We are unable to change the hostname at the moment. Tried changing the node name using configuration but unable to find success.

is there anything we can do to overcome the issue?


Solution

  • You can write small bash script and use it to startup agent with random uuid as name by providing config file name override upon first run:

        FILE=/etc/consul.d/host_id.hcl
        if [ ! -f "$FILE" ]; then
            echo "node_name=$(uuidgen)" > "$FILE"
        fi
        consul agent -config-file=$FILE #... use your your agent run command with loading file config override