Skip to content

Commit

Permalink
get pods from all namespaces for nodes command
Browse files Browse the repository at this point in the history
  • Loading branch information
voldemortensen committed Sep 10, 2021
1 parent ecffb19 commit 07c07f0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
12 changes: 12 additions & 0 deletions util/k8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"}...)

Expand Down

0 comments on commit 07c07f0

Please sign in to comment.