Client-go: How to get all pods running in a given node.

Created on 16 May 2018  路  2Comments  路  Source: kubernetes/client-go

I am trying to get all pods in a given node. Can list all nodes by following but node struct having NodeSpec and NodeStatus does not have container information.

nodes, _ := clientset.CoreV1().Nodes().List(metav1.ListOptions{})

Most helpful comment

Use a field selector

nodeName := "my-node"
pods, err := clientset.CoreV1().Pods("").List(metav1.ListOptions{
    FieldSelector: "spec.nodeName=" + nodeName,
})

/close

All 2 comments

Use a field selector

nodeName := "my-node"
pods, err := clientset.CoreV1().Pods("").List(metav1.ListOptions{
    FieldSelector: "spec.nodeName=" + nodeName,
})

/close

Tks

Was this page helpful?
0 / 5 - 0 ratings

Related issues

protheusfr picture protheusfr  路  3Comments

tamalsaha picture tamalsaha  路  6Comments

AdheipSingh picture AdheipSingh  路  5Comments

vklonghml picture vklonghml  路  4Comments

jgrobbel picture jgrobbel  路  3Comments