<p>I am new to Kubernetes and I need to do some customizations using API's. My aim is to get pods from all zones of cluster or specific zones.  Using Kubernetes API and Golang I am able to get list of Pods and list of Nodes but i am unable to  find any interface which will give me list of Zones and interface which will give me list of Pods within zone.</p>
<p>Need guidance on how I can achieve this.</p>

Rajjy
<p>You can get info about node Zone and Region by reading its <code>labels</code>. You can check out well-known labels here: <a href="https://kubernetes.io/docs/reference/labels-annotations-taints/#topologykubernetesiozone" rel="nofollow noreferrer">https://kubernetes.io/docs/reference/labels-annotations-taints/#topologykubernetesiozone</a>.</p>
<p>You can build from this information about placement nodes in zones. Next you can <code>get pods</code> and filter the output by field selector.
Found example on GH: <a href="https://github.com/kubernetes/client-go/issues/410" rel="nofollow noreferrer">https://github.com/kubernetes/client-go/issues/410</a></p>
<pre class="lang-golang prettyprint-override"><code>nodeName := &quot;my-node&quot;
pods, err := clientset.CoreV1().Pods(&quot;&quot;).List(metav1.ListOptions{
    FieldSelector: &quot;spec.nodeName=&quot; + nodeName,
})
</code></pre>
