How to get the pod definition file from kubectl command

When I use command kubectl get pod -o yaml
it gives the pod definition file with the system generated values also
is there any command that gives the pod definition file without system generated values after pod is created.

Hi @saireddybonthu

kubectl get fetches the current state of the resource and prints it on the user’s terminal. Hence, dumps the status and other metadata too. The --output presents the output in many formats, one being --jsonpath.

You can use --jsonpath to filter the fields you are interested in.

For example:
kubectl get pod box -o jsonpath="{.spec.containers[].image}"

Hope this helps.

1 Like

Thanks
For cka exams
When we want to kubectl edit pod spec where it is not allowed but then it stores in a tmp folder but that to contains status and other metadata.
Is there any kubectl command that can get the pod definition file for running pod.