diff --git a/cmd/nodes.go b/cmd/nodes.go index 98ec098..bdc3b06 100644 --- a/cmd/nodes.go +++ b/cmd/nodes.go @@ -79,7 +79,7 @@ func NewPodStatus(pod v1.Pod) PodStatus { } func nodeMap() map[string]NodePodInfo { - podList := util.GetPodList(namespace, context, labels) + podList := util.GetPodListAllNamespaces(context, labels) nodeMap := make(map[string][]v1.Pod) for _, pod := range podList.Items { diff --git a/util/k8s.go b/util/k8s.go index 00085b5..3e83304 100644 --- a/util/k8s.go +++ b/util/k8s.go @@ -100,6 +100,18 @@ func GetDeploymentList(namespace string, context string, labels string) appsv1.D return deployList } +func GetPodListAllNamespaces(context string, labels string) corev1.PodList { + podString := RawK8sOutputString("", context, labels, []string{"get", "pods", "--all-namespaces", "-o", "json"}...) + + var podList corev1.PodList + err := json.Unmarshal([]byte(podString), &podList) + if err != nil { + log.Fatal(err) + } + + return podList +} + func GetPodList(namespace string, context string, labels string) corev1.PodList { podString := RawK8sOutputString(namespace, context, labels, []string{"get", "pods", "-o", "json"}...)