Why is it that almost every time I do the: kubectl get pod <podname> -o ya . . .

Ethan Benedict:
Why is it that almost every time I do the:
kubectl get pod <podname> -o yaml > filename.yaml command I get a bunch of random managed feilds?
Kubernetes command.PNG

Vagif Gafar:
This is the full definition of an object, with all default fields that exist in k8s, these are often not used or used for more thorough pods definitions. You can reduce output adding:
-o yaml | grep -v {}

Ethan Benedict:
ok thank you

Mohamed Ayman:
Also, it is recommend to use yaml file to create ur object instead of the kubectl.

Ionut:
@Ethan Benedict kubectl v1.21 does not have managedfields enabled by default, but can be added using --show-managed-fields

Ionut:
https://github.com/kubernetes/kubernetes/issues/90066
https://github.com/kubernetes/kubernetes/pull/96878

Ionut:

kubectl version --short       
Client Version: v1.21.1

k get po nginx -o yaml --show-managed-fields | wc -l
147
---
k get po nginx -o yaml | wc -l                      
84

Ethan Benedict:
I dont want the managed fields in the yaml file. How do i get rid of them?

Ethan Benedict:
or prevent it from creating when I forward the pod definition into a file

Ionut:
@Ethan Benedict I’ve told you …use kubectl version 1.21 :slightly_smiling_face: