<p>How can I list, using command line, all the pods running in the nodes of a particular instance group?</p>

<p>For example, if I have instancegroup "Foo", which has let's say three nodes, N1, N2, and N3, that in turn have pods A and B running on N1, pods C, D and E running on N2, and pod F running on N3.... how can I, using kops/kubectl, make query with input "Foo" and output "A, B, C, D, E, F"?</p>

<p>I know that you can query a particular node and list all the pods in it, but I want to query an instancegroup, with many nodes, and get all the pods across all the nodes, with no namespace constraint.</p>

<p>Thanks!</p>

<p>One way would be to assign labels to the nodes in your InstanceGroup, perhaps with the name of the instance group (for simplicity) and then use a combination of kubectl commands to query.</p>

<p>So in your InstanceGroup spec set <code>nodeLabels</code> to be <code>ig: Foo</code> (see <a href="https://github.com/kubernetes/kops/blob/master/docs/instance_groups.md#adding-taints-or-labels-to-an-instance-group" rel="nofollow noreferrer">https://github.com/kubernetes/kops/blob/master/docs/instance_groups.md#adding-taints-or-labels-to-an-instance-group</a>) for details and then run:</p>

<p><code>kubectl get pods -o wide --all-namespaces | grep -F -f &lt;(kubectl get nodes -l ig=Foo --no-headers | awk '{print $1}')</code></p>
