-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot set readOnlyRootFilesystem for ui container #4
Comments
I also wanted to raise an issue for this. We have the same approach forcing every workload to set the field For was implemented. Now we are unable to workaround this. Update: But it still seems not possible. |
Actually no, because I missed this second part. Currently, we run opencost with an exception to the rule. My hope is that this fixes all of the places where it is needed. But if you can check again, that would be great. 4-eyes more than 2 :) |
I still get the message in version 1.111.0
Has anyone managed to overcome this problem? |
has there been any fix or known workaround? |
This worked for me: # values.yaml
opencost:
ui:
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: false
runAsNonRoot: true
runAsUser: 1001
extraVolumeMounts:
- name: empty-var-www
mountPath: /var/www
extraVolumes:
- name: empty-var-www
emptyDir: {} |
I also encountered this issue today. I'll try the emptyDir workaround, but a proper fix would be nice... |
OK, the error changed:
(Please note that I am not using Using |
It's not a fix to the underlying problem but in our case this workaround helped getting a modified default.nginx.conf.template into the game: values.yaml opencost:
ui:
extraVolumeMounts:
- name: opencost-ui-nginx-config-volume
mountPath: /etc/nginx/conf.d/default.nginx.conf.template
subPath: default.nginx.conf.template
extraVolumes:
- name: opencost-ui-nginx-config-volume
configMap:
name: opencost-ui-nginx-config The configMap itself is provided by kustomize which we use around helm. |
But then the |
This seems to work:
I created a PR to changed the opencost-ui entrypoint script to only create the default.nginx.conf, if it does not exist. This way people could mount the configuration file from a configMap directly. The |
Okay, nice. I can't currently recall where I read it or if it was just figured out by looking at it in the pod, but the volume mount basically overwrote the securityContext configuration leading to the permission denied error you mentioned above. The subPath hack, somehow, does not have this problem. |
only create /etc/nginx/conf.d/default.nginx.conf if it does not yet exist (fix #4)
Describe the bug
As a mandatory K8S cluster hardening policy in our organisation it's required to set
readOnlyRootFilesystem
for each container inside a pod.The actual issues are with the docker-entrypoint script: https://github.com/opencost/opencost/blob/develop/ui/docker-entrypoint.sh#L21
It tries to write a few files to the root volume (
/var/www
and/etc/nginx/conf.d
).In case of
/var/www
it was possible to workaround the issue by attaching a writable emptyDir volume to/var/www
, however the same approach was not possible with/etc/nginx/conf.d
, because mounting a volume on that path hides files that are already existing on that path (entrypoint script tries to read config template to use for envsubst).This issue makes the pod unable to start (CrashLoopBackoff).
To Reproduce with the tried workaround
Steps to reproduce the behavior:
Using the following helm values:
To Reproduce with the described workaround (still failing)
Steps to reproduce the behavior:
Using the following helm values:
Expected behavior
Pod starts up correctly with readonly root filesystem
Screenshots
Not relevant
Which version of OpenCost are you using?
OpenCost: v1.109.0
Helm chart: v1.32.0
Additional context
None
The text was updated successfully, but these errors were encountered: