Skip to content

Commit

Permalink
Show hostName other than podName
Browse files Browse the repository at this point in the history
Signed-off-by: wanglijie6 <wanglijie6@xiaomi.com>
  • Loading branch information
wanglijie6 committed Apr 12, 2022
1 parent 79bb860 commit 588c1a0
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions pkg/goldpinger/k8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ package goldpinger

import (
"context"
"go.uber.org/zap"
"io/ioutil"

"go.uber.org/zap"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
k8snet "k8s.io/utils/net"
Expand Down Expand Up @@ -93,6 +94,14 @@ func getPodIP(p v1.Pod) string {
return podIP
}

func getPodNodeName(p v1.Pod) string {
if p.Spec.NodeName != "" {
return p.Spec.NodeName
}

return p.Name
}

// GetAllPods returns a mapping from a pod name to a pointer to a GoldpingerPod(s)
func GetAllPods() map[string]*GoldpingerPod {
timer := GetLabeledKubernetesCallsTimer()
Expand All @@ -111,7 +120,7 @@ func GetAllPods() map[string]*GoldpingerPod {
podMap := make(map[string]*GoldpingerPod)
for _, pod := range pods.Items {
podMap[pod.Name] = &GoldpingerPod{
Name: pod.Name,
Name: getPodNodeName(pod),
PodIP: getPodIP(pod),
HostIP: getHostIP(pod),
}
Expand Down

0 comments on commit 588c1a0

Please sign in to comment.