How can we identify and locate the pod definition files of any specific pod that . . .

kandulaz IOT:
how can we identify and locate the pod definition files of any specific pod that is running

kandulaz IOT:
kubectl get pods lists about 7 pods running, I am looking forward to identify the pod definition yaml file

unnivkn:
kubectl run mypod --image=nginx --dry-run=client -oyaml>mypod.yaml

Joe:
The above should work, unless its a static pod. If it is, then you will likely find the pod manifest located at /etc/kubernetes/manifests

This is the default location that kubelet looks for the static pod files

Tej_Singh_Rana:
In case, if pod is already running.

kubectl get po <pod-name> -oyaml 


If want to store in a file then use " > file.yaml" in the end.

Hi,
If we create a pod using kubectl run mypod
Wanted to know about the default location of pod-definition.yaml

There isn’t one. There’s no guarantee such a file would even exist.

To the extent information is stored anywhere, it’s as records in etcd.

1 Like

Got it.
Also if we have to edit such pods for image change or labels we delete the pod and create the new as required?

Yes, that’s what you need to do. Some resource types you can edit after they exist (deployments and services are examples of this). But pods you really can’t edit; you need to recreate them by:

  • getting their yaml from a file or saving yaml away (kubectl get po PODNAME -o yaml > file.yaml)
  • editing the yaml file to what you need it to be.
  • delete the existing pod.
  • apply the yaml file to create a new version of the pod.