Poorni:
Hi, kubectl get podname -o yaml > p.yaml produces yaml file but with additional things like managed fields.
managedFields:
- apiVersion: v1
fieldsType: FieldsV1
fieldsV1:
f:spec:
f:containers:
k:{“name”:“mem-stress”}:
.: {}
f:args: {}
f:command: {}
f:image: {}
f:imagePullPolicy: {}
f:name: {}
f:resources:
.: {}
is there a way to avoid this . Please advise
Preetham Umarani:
+1 looking for answers
Tej_Singh_Rana:
Hello, @Poorni
You can use grep
command.
kubectl get po webapp -oyaml | grep -v 'f:' > pod.yaml
Tej_Singh_Rana:
After that you will see only a few managedFields
. So you can use dd
shortcut in VI editor to delete those lines.
To delete the multiple lines, you can use Ndd
.
N - numbers
Tej_Singh_Rana:
To delete 10 lines, use 10dd
chris resnik:
the --export switch helped, but that was deprecated
chris resnik:
is there a replacement for --export ?
Tej_Singh_Rana:
No replacement, use dd
shortcut in VI editor to delete those lines.
Poorni:
do we need this to do in exam too
Tej_Singh_Rana:
> do we need this to do in exam too
It won’t affect to your work, you can leave as it is.
Tej_Singh_Rana:
> Why are these extra fields getting created
https://kubernetes.io/blog/2020/04/01/kubernetes-1.18-feature-server-side-apply-beta-2/#how-does-it-work-what-s-managedfields
Mohamed Ayman:
there’s no way to prevent this and only use the grep command to exclude them as you can.