-
Notifications
You must be signed in to change notification settings - Fork 22
Support for running with a read-only root filesystem #226
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
Conversation
…urity. This involves an init container that merges configuration items from defaults and any overrides.
|
@wkbrd I fixed the template syntax error, in a separate PR. If you merge/rebase master, it should be fixed. It looks like there are 2 separate issues in this PR:
|
|
Hi @sklarsa , In my testing/environment, if one is only overriding a single setting file (e.g., serverConfig), then I am observing that the container will not start properly. Here is an example: With the following container log before the container crashes: The usage of this helm install command currently fails on the mainline questdb chart (excluding this PR). This fails with an initial installation (i.e., no PersistentVolumeClaim prior to the helm install). Providing multiple config items (logConfig) can mitigate this. This PR includes a mitigation by using an initContainer that copies in the override files and by doing so, the main container launch properly will copy in the non-overridden files. However, if the install arguments above were to work properly (and also is confirmed to work with questdb.configStorageType=secret), then this PR would likely get simpler and not need the initContainer for the config prep and associated override_conf/merged_conf. Should someone attempt to address the problem above first before we proceed with read-only root filesystem changes? |
Yes, I will take a look at reproducing and fixing the problem this week. Thanks for pointing it out! |
|
This appears to a be a permissions issue inside the container. We're running as user Running a shell inside the container... We usually avoid this issue in our By explicitly creating the file (or dir) beforehand with a volume mount, the issue is avoided. I need to think about our options here. I'm leaning towards reverting the security context defaults we set earlier in #223. In that case, I would leave the key available for you to customize the Because our docker container is used in a wide variety of orchestration tools, I'm hesitant to start making further changes to the entrypoint at this time. What do you think? |
…into readonly_root_filesystem
|
Hi @sklarsa , the config-mount changes (part 2 in your original comment) in this PR accommodates this problem by making the conf directory writeable. The overrides are copied into the temporary volume during container startup. Then when the main container runs, it is able to add the default files (non-overridden) as you are mentioning. It is important for security reasons that the container to be designed to be an immutable container and that writeable areas are properly handled/designated in them. Excluding the securityContext.readOnlyRootFilesystem setting in values.yaml (line 17), are you OK with the changes in this PR to allow the optional overrides to work? |
|
@wkbrd I understand that this PR technically solves the problem, but in my opinion, it adds unnecessary complexity to the helm chart as a whole. I prefer to structure the helm chart to allow users to layer in additional security configurations to fulfill their organization's specific needs. This way, we can ensure that the default helm chart will work across as wide of a user base as possible. As we've seen, the default security context changes have already caused one issue fairly early on in the database execution path. And there may be more things that we aren't able to catch without extensive testing all possible combinations of helm chart values, command line flags, and database versions. Because of this, I am going to remove the securityContext and podSecurityContext default values set in #223 in a new PR. Based on your requirements, you are free to update initContainers, securityContext, and podSecurityContext to fit your needs. I really appreciate the work that you've put into this over the past few weeks. I understand the importance of security-by-default, but I need to weigh this against the risk of difficult-to-debug outages as a result of helm chart updates. |
Immutable container file systems are detailed as a recommendation in the CISA Kubernetes Hardening Guide.
https://www.cisa.gov/news-events/alerts/2022/03/15/updated-kubernetes-hardening-guide
Additional details on the security benefits of this change:
Support for running with a read-only root filesystem for improved security. The implementation involves an init container that merges configuration items from defaults and any overrides.