由于无效字符,将无法通过DNS发现Consul节点

问题描述 投票:1回答:1

我们主要是基于VM的环境,其中包含许多微服务,需要客户端发现,配置管理等。因此决定使用Hashicorp Consul。

我们面临一个问题:带有点号(。)的主机名

[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.

目前我们无法更改主机名。尝试使用配置更改节点名称,但无法成功。

我们有什么办法可以解决这个问题?

consul
1个回答
0
投票

您可以编写小型bash脚本,并通过在首次运行时提供random uuid来使用它以config file name override作为名称来启动代理:

    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
© www.soinside.com 2019 - 2024. All rights reserved.