<p>I know how to list of pods for certain namespace as follows:</p>
<pre><code>kubectl get pods -n mynamespace
</code></pre>
<p>There is one <code>POD</code> on the list which i am interested. I would like to be able to see what <code>yaml</code> deployment file was used for creation of that pod and the content of it. Moreover what would be <code>kubectl</code> command to edit such <code>yaml</code> file?</p>

<p>To get the deployment used to generate a pod, have to look at the pod yaml or describe the pod:</p>
<pre><code>kubectl get pod -n {namespace} {pod-name} -o yaml
</code></pre>
<p>Look for the &quot;<code>ownerReferences</code>&quot; section. This will tell you what &quot;owns&quot; the pod. This will likely be a ReplicaSet (which is generated by the Deployment). For example, this is my one from my canonical-service-controller-manager pod:</p>
<pre><code>$ kubectl get  pod -n asm-system canonical-service-controller-manager-67c8f5fff5-dzd4t -o yaml
apiVersion: v1
kind: Pod
metadata:
  ...
  namespace: asm-system
  ownerReferences:
  - apiVersion: apps/v1
    blockOwnerDeletion: true
    controller: true
    kind: ReplicaSet
    name: canonical-service-controller-manager-67c8f5fff5
    uid: 2504c96b-9ef7-45fa-b5d2-2a20f09486e1
  resourceVersion: &quot;13507&quot;
  uid: 54748cf7-26f8-4e8a-996a-725dbc89c66b
...
</code></pre>
<p>You can then find the replicaset and do the same thing. In my example, the replicaset is called &quot;<code>canonical-service-controller-manager-67c8f5fff5</code>&quot;</p>
<pre><code>$ kubectl get replicaset -n asm-system canonical-service-controller-manager-67c8f5fff5 -o yaml
apiVersion: apps/v1
kind: ReplicaSet
metadata:
  annotations:
    ...
  generation: 1
  labels:
    ...
  name: canonical-service-controller-manager-67c8f5fff5
  namespace: asm-system
  ownerReferences:
  - apiVersion: apps/v1
    blockOwnerDeletion: true
    controller: true
    kind: Deployment
    name: canonical-service-controller-manager
    uid: eafe2590-5005-492f-9673-0f02ac74a4d5
spec:
  replicas: 1
  ...
</code></pre>
<p>So you can see here, the deployment that created the replicaset, which in turn created my pod is <code>canonical-service-controller-manager</code></p>
<p>So now I can get the deployment yaml using</p>
<pre><code>$ kubectl get deployment -n asm-system canonical-service-controller-manager -o yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    ...
  creationTimestamp: &quot;2022-06-14T06:35:58Z&quot;
  generation: 1
  labels:
    ...
  name: canonical-service-controller-manager
  namespace: asm-system
spec:
  ...
</code></pre>
<p>If I wanted to edit the deployment, I can do so using this:</p>
<pre><code>kubectl edit deployment -n asm-system canonical-service-controller-manager
</code></pre>
<p>Bear in mind, that editing the deployment will cycle all the pods in the deployment as they are all replicas.</p>
