Is there a way to use kubectl
to list only the pods belonging to a deployment? Currently I do this to get pods:
kubectl get pods| grep hello
But it seems an overkill to get ALL the pods when I am interested to know only the pods for a given deployment. I use the output of this command to see the status of all pods, and then possibly exec into one of them.
I also tried kc get -o wide deployments hellodeployment
, but it does not print the Pod names.
There's a label in the pod for the selector in the deployment. That's how a deployment manages its pods. For example for the label or selector app=http-svc
you can do something like that this and avoid using grep
and listing all the pods (this becomes useful as your number of pods becomes very large):
$ kubectl get pods -l=app=http-svc
or
$ kubectl get pods --selector=app=http-svc