Hi experts, I have got one more question, which is w.r.t securityContext. This . . .

Vasu BK:
Hi experts,
I have got one more question, which is w.r.t securityContext. This contains two parts. Questions are

  1. if I add securityContext to an existing pod with “kubectl edit …” option, its not getting applied. I tried to delete the pod and recreated the pod with modified/edited yaml file. Still it doesn’t work. It works only if I recreate the pod with altogether a fresh yaml file.
  2. Lets say I created a pod with a new yaml file with securityContext added to it. But, when I wanted to see the details with “kubectl edit …”, it doesn’t show the details.

Would you please educate me on those points…!!! Thanks in advance.

Tej_Singh_Rana:
Hello, @Vasu BK

  1. Maybe there is one more empty securityContext field. Like
    securityContext: {}
    Use vi editor search option.
    • /security
  2. You can use kubectl get po <pod-name> -oyaml

Vasu BK:
Hi Tej,
Thank u very much. U r right, the section is a bit down in the file. When I updated it and recreated the pod, it worked. However, it didn’t work with "kubectl apply -f " option. I had to delete and recreate.

Kindly clarify one more thing in this context. Earlier, when I missed to notice the empty securityContext section, I was adding a new section ahead of the existing empty section. So, when I define an additional section, why doesn’t it take into consideration? Kindly clarify