Skip to content

Commit 07c07f0

Browse files
get pods from all namespaces for nodes command
1 parent ecffb19 commit 07c07f0

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

cmd/nodes.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func NewPodStatus(pod v1.Pod) PodStatus {
7979
}
8080

8181
func nodeMap() map[string]NodePodInfo {
82-
podList := util.GetPodList(namespace, context, labels)
82+
podList := util.GetPodListAllNamespaces(context, labels)
8383

8484
nodeMap := make(map[string][]v1.Pod)
8585
for _, pod := range podList.Items {

util/k8s.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,18 @@ func GetDeploymentList(namespace string, context string, labels string) appsv1.D
100100
return deployList
101101
}
102102

103+
func GetPodListAllNamespaces(context string, labels string) corev1.PodList {
104+
podString := RawK8sOutputString("", context, labels, []string{"get", "pods", "--all-namespaces", "-o", "json"}...)
105+
106+
var podList corev1.PodList
107+
err := json.Unmarshal([]byte(podString), &podList)
108+
if err != nil {
109+
log.Fatal(err)
110+
}
111+
112+
return podList
113+
}
114+
103115
func GetPodList(namespace string, context string, labels string) corev1.PodList {
104116
podString := RawK8sOutputString(namespace, context, labels, []string{"get", "pods", "-o", "json"}...)
105117

0 commit comments

Comments
 (0)