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

<pre><code>kubectl get -f deployment.yml
</code></pre>

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

<p>Even if i use the <code>-o json</code> option still unable to get the pod names.</p>

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

<p>my deployment file looks below </p>

<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    ansible: test-2020-05-26-00-04-1590476651
    podRef: pod-ansibles
  name: rd-2020-05-26-00-04-1590476651
spec:
  replicas: 2
  selector:
    matchLabels:
      app: nginx
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: nginx
        ...
        ....
</code></pre>

<p>so is there any way that i can get all pods which has deployment label 'test-2020-05-26-00-04-1590476651' ?</p>

<p>when i tried <code>'kubectl get pod -l ansible=test-2020-05-26-00-04-1590476651'</code> . it shows </p>

<p><code>'No resources found in default namespace.'</code> seems it can only display deploy name <code>'kubectl get deploy -l ansible=test-2020-05-26-00-04-1590476651'</code></p>

<p>But i need all pod names which is under a deployment..</p>

Samselvaprabu
<p>Usually, we label deployment's pods.</p>

<pre><code>  template:
    metadata:
      labels:
        app: my-app
</code></pre>

<p>So, we can get all pod filter by label</p>

<pre><code>kubectl get pod -l app=my-app
</code></pre>
