I am trying to retrieve yaml/json definition of the Pods running on the cluster. Is there any way with the help of kubectl, python client ?
I have tried it using Python Client with list_namespaced_pod function for watching the stream, But Objects has lot of extra fields with 'None' values.
For example if I create a Busybox Pod, I need the command to retrieve the exact definition used to spawn the pod.
How can I achieve the task ?
Try using kubectl get pod POD_NAME -o yaml --export
. The --export
option will strip the output YAML of any cluster specific information. However, it will create a YAML with lots of fields that are populated by default values since this is what the API server sees. When you make a very simple pod definition and deploy it, you are effectively overwriting default values for optional pod attributes, and populating the non-optional attributes.