1
0
mirror of https://github.com/rancher/rke.git synced 2025-09-25 14:48:06 +00:00

Fix etcd listen address edge case when public address is DNATed

This commit is contained in:
moelsayed
2018-04-20 06:07:44 +02:00
committed by Darren Shepherd
parent d11221c604
commit f1e39f9b10

View File

@@ -537,13 +537,19 @@ func (c *Cluster) BuildEtcdProcess(host *hosts.Host, etcdHosts []*hosts.Host, pr
"--client-cert-auth", "--client-cert-auth",
} }
// If InternalAddress is not explicitly set, it's set to the same value as Address. This is all good until we deploy on a host with a DNATed public address like AWS, in that case we can't bind to that address so we fall back to 0.0.0.0
listenAddress := host.InternalAddress
if host.Address == host.InternalAddress {
listenAddress = "0.0.0.0"
}
CommandArgs := map[string]string{ CommandArgs := map[string]string{
"name": "etcd-" + host.HostnameOverride, "name": "etcd-" + host.HostnameOverride,
"data-dir": "/var/lib/rancher/etcd", "data-dir": "/var/lib/rancher/etcd",
"advertise-client-urls": "https://" + host.InternalAddress + ":2379,https://" + host.InternalAddress + ":4001", "advertise-client-urls": "https://" + host.InternalAddress + ":2379,https://" + host.InternalAddress + ":4001",
"listen-client-urls": "https://" + host.InternalAddress + ":2379", "listen-client-urls": "https://" + listenAddress + ":2379",
"initial-advertise-peer-urls": "https://" + host.InternalAddress + ":2380", "initial-advertise-peer-urls": "https://" + host.InternalAddress + ":2380",
"listen-peer-urls": "https://" + host.InternalAddress + ":2380", "listen-peer-urls": "https://" + listenAddress + ":2380",
"initial-cluster-token": "etcd-cluster-1", "initial-cluster-token": "etcd-cluster-1",
"initial-cluster": initCluster, "initial-cluster": initCluster,
"initial-cluster-state": clusterState, "initial-cluster-state": clusterState,