How to get pod names from deployment?

5/29/2020

We have created deployments which in turns creates pod. I need to get the Pod names created by my deployment file.

kubectl get -f deployment.yml

The above command list the deployment names. If i type kubectl get pod it displays the pod names which is having some random extra strings added with deployment names.

Even if i use the -o json option still unable to get the pod names.

How to get all the pods created by deployment? Even a shell script way would be fine.

-- Samselvaprabu
kubernetes
kubernetes-pod
shell

1 Answer

5/29/2020

Usually, we label deployment's pods.

  template:
    metadata:
      labels:
        app: my-app

So, we can get all pod filter by label

kubectl get pod -l app=my-app
-- RammusXu
Source: StackOverflow