From f0a5f88b955c60fc400485fcbeb1f44727175a1a Mon Sep 17 00:00:00 2001 From: Tariq Ibrahim Date: Tue, 20 Aug 2019 07:52:11 -0700 Subject: [PATCH] [prometheus_sd/kubernetes]add new node address types for discover (#5902) Signed-off-by: Tariq Ibrahim --- discovery/kubernetes/node.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/discovery/kubernetes/node.go b/discovery/kubernetes/node.go index 439d76839..973be2809 100644 --- a/discovery/kubernetes/node.go +++ b/discovery/kubernetes/node.go @@ -196,9 +196,11 @@ func (n *Node) buildNode(node *apiv1.Node) *targetgroup.Group { // nodeAddresses returns the provided node's address, based on the priority: // 1. NodeInternalIP -// 2. NodeExternalIP -// 3. NodeLegacyHostIP -// 3. NodeHostName +// 2. NodeInternalDNS +// 3. NodeExternalIP +// 4. NodeExternalDNS +// 5. NodeLegacyHostIP +// 6. NodeHostName // // Derived from k8s.io/kubernetes/pkg/util/node/node.go func nodeAddress(node *apiv1.Node) (string, map[apiv1.NodeAddressType][]string, error) { @@ -210,9 +212,15 @@ func nodeAddress(node *apiv1.Node) (string, map[apiv1.NodeAddressType][]string, if addresses, ok := m[apiv1.NodeInternalIP]; ok { return addresses[0], m, nil } + if addresses, ok := m[apiv1.NodeInternalDNS]; ok { + return addresses[0], m, nil + } if addresses, ok := m[apiv1.NodeExternalIP]; ok { return addresses[0], m, nil } + if addresses, ok := m[apiv1.NodeExternalDNS]; ok { + return addresses[0], m, nil + } if addresses, ok := m[apiv1.NodeAddressType(NodeLegacyHostIP)]; ok { return addresses[0], m, nil }