Skip to content

Commit 5fce5fe

Browse files
Prachi DamlePrachi Damle
Prachi Damle
authored and
Prachi Damle
committed
Use the public ip from host labels if provided in metadata, otherwise
use the host agent's ip The label from metadata is 'io.rancher.host.external_dns_ip'
1 parent 340f2f3 commit 5fce5fe

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

metadata/metadata.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,13 @@ func (m *MetadataClient) getContainersDnsRecords(dnsEntries map[string]dns.DnsRe
9797
logrus.Infof("%v", err)
9898
continue
9999
}
100-
ip := host.AgentIP
100+
101+
ip, ok := host.Labels["io.rancher.host.external_dns_ip"]
102+
103+
if !ok || ip == "" {
104+
ip = host.AgentIP
105+
}
106+
101107
fqdn := dns.ConvertToFqdn(container.ServiceName, container.StackName, m.EnvironmentName)
102108
records := []string{ip}
103109
dnsEntry := dns.DnsRecord{fqdn, records, "A", dns.TTL}

0 commit comments

Comments
 (0)