Home > OS >  How can I get the node where the pod is located using kubernetes python client?
How can I get the node where the pod is located using kubernetes python client?

Time:11-30

I have a Pod name and I want to know where the Pod is located using kubernetes python client. Is it possible to use kubernetes python client in order to get the node name by Pod? (Just like the NODE column in kubectl get pod -o wide)

I've referred to the document https://github.com/kubernetes-client/python/blob/master/kubernetes/README.md. But I didn't find a solution.

CodePudding user response:

I think read_namespaced_pod has the information (spec.nodeName).

https://github.com/kubernetes-client/python/blob/master/kubernetes/docs/CoreV1Api.md#read_namespaced_pod

  • Related