How can I list, using command line, all the pods running in the nodes of a particular instance group?
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"?
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.
Thanks!
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.
So in your InstanceGroup spec set nodeLabels
to be ig: Foo
(see https://github.com/kubernetes/kops/blob/master/docs/instance_groups.md#adding-taints-or-labels-to-an-instance-group) for details and then run:
kubectl get pods -o wide --all-namespaces | grep -F -f <(kubectl get nodes -l ig=Foo --no-headers | awk '{print $1}')