Hi All, I am bit confused when to use "kubectl edit" to modify a pod instead of . . .

Jees Antony:
Hi All, I am bit confused when to use “kubectl edit” to modify a pod instead of delete and recreation.

I get below error when I try to add securitycontext-runAsuser using “kubectl edit” .

controlplane k edit pod ubuntu-sleeper Edit cancelled, no changes made. controlplane

Obviously, I will do it with delete/recreation but just wondering why “kubectl edit” is not working here and when I can use it (As “kubectl edit” is faster than delete/recreation) .

OE:
When editing pods, you can only use edit to modify things that will not result in the pod restarting. If you change the image or some other field (like the securityContext), this requires a restart for it to be applied. In this case, edit fails. But if you use it to do something like add a label or some other metadata, it works