Issue with security context


I am facing issue in adding security context runasuser. It is giving error as soon as I add the line

Can anyone help me

Thank you

Hi @vishalnhy,
What kind of error are you getting?


Hello @vishalnhy,

Please follow the template from k8s docs to configure your securityContext (Configure a Security Context for a Pod or Container | Kubernetes). If the issue still appears, please share your pod/deployment YAML file so that we can have a look.



I also confirm facing an issue in the Security Context lab, when adding

runAsUser: 1010

at the pod spec level (it worked fine when set at the container level).
Editing the pod definition and saving gives “Edit cancelled, no changes made.”,
so it seems the change is being rejected.
Reproduced the same behavior in local minikube installation.

Is it possible that setting security context at pod level has been disallowed/deprecated??

Thank you.

I tracked down the issue. When the pod is created without any securityContext specified, its containers automatically assume: securityContext: {} , which means the default settings (thus, user root).

When we “kubectl edit” the pod definition, if we want to add security context at the pod level, we must first delete those fields from the container level of our pod containers. If we don’t, the container level security context, despite being “empty”, takes precedence.

Hope this helps others that faced the same issue.

Best regards

Thanks for your research, @dimitris.giatsios :+1: