Guidance on .NET 8 non-root container in K8S accessing a secret mounted as a volume? #5061
-
BackgroundI am newer to Kubernetes and am willing to bet this may be a gap in my knowledge but I can't determine what it is. We upgraded to .NET 8 containers seamlessly -- worked great! 🎉 Now I'm in the process of locking things down a little bit more, including running as a non-root user. I have:
ChallengeThis Kubernetes pod has a secret binding that shows up as a volume mount. Our app reads this file at runtime. We're now getting permission errors when trying to read the file located in the binding mount, which I think makes sense, because the volume would be mounted by root as default, and thus preventing access. (though I'm pretty new to this). I have tried:
QuestionAre there any guidance or examples of using .NET 8 non-root containers and reading from mounted volumes? If not, I'm willing to contribute back to the docs/samples once I understand it fully. Any help is appreciated! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
It turns out, I spoke too soon! I must have posted this before appropriately trying the fix. After isolating the fix, the key change was adding |
Beta Was this translation helpful? Give feedback.
It turns out, I spoke too soon! I must have posted this before appropriately trying the fix.
After isolating the fix, the key change was adding
fsGroup: 2000
to the pod'ssecurityContext
. I didn't need the additionalrunAsUser
commands.