-
Notifications
You must be signed in to change notification settings - Fork 66
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
K8SSAND-962 ⁃ Investigate making the root file system in cassandra container read-only #199
Comments
This is needed in support of k8ssandra/cass-operator#199.
This is needed in support of k8ssandra/cass-operator#199.
There are additional changes needed. The management-api writes to /opt. Logs are written to /var/log/cassandra. This makes a number of places where we need to introduce volume mounts. This begs the question of whether we want to continue using init containers to copy things around as we are currently doing or make changes in the images themselves. I did some prototyping for this earlier in the week. I pushed it here https://github.com/jsanda/cass-operator-1/tree/non-root-fs-cassandra. I do not think that the current solution with copying stuff with init containers is a scalable and maintainable solution. I think we would we better off in the long run to update the images with the necessary changes. Note that investigation is still required to determined what all is necessary. The management-api uses base images of Cassandra from https://github.com/docker-library/cassandra. We might need a different base image that is designed with a read-only root file system in mind. Ultimately I think we have to configure the containers with read-only root file systems to discover all the changes that are necessary. I will revisit my prototype to get a better sense of what is involved and then start trying to break the work down into smaller tickes. |
I thought some more about config files/directories, /etc/cassandra in particular. Here is what I propose we do: Store all config files in a ConfigMap. It becomes part of the operator installation. We need a ConfigMap for each Cassandra version that the operator supports. The ConfigMap can be installed via Kustomize or Helm along with all other operator resources. To be clear, I am not suggesting we generate the ConfigMap in the operator Go code. We add a ConfigMap volume to the StatefulSet. The ConfigMap volume should be ready only. It will have the appropriate base configuration. Each pod needs its own configuration though. We add an EmptyDir volume for /etc/cassandra. An init container with a volume mount for the ConfigMap will copy the base configuration onto the /etc/cassandra volume. This init container should run before any other init containers. Currently the management-api's entry point script copies files generated by config-builder over to /etc/cassandra (see here). I don't think that will be necessary any more. The config builder init container can write directly to the /etc/cassandra volume mount. In k8ssandra I think we could get rid of the |
This sounds good to me. My only question is if this is sufficient for the read-only root filesystem, or if this is just a part of the solution as it seems it only addresses write to |
My idea is only focused on addressing |
I am doing some more work on this and wanted to point out that there is already an EmptyDir volume for There is already a PersistenVolume for
|
@emerkle826 @burmanm, I think this is what we'll be discussing next week around moving more logic into the Dockerfiles and remove it from the entrypoint, right? |
This would be one of the tickets (involving cass-operator changes for new empty mounts). |
Why do we need it?
The root file system should be read-only for improved security. This is considered a best practice for security.
#196 was created specifically for DSE. The goal for this ticket is to address both OSS Cassandra and DSE. If it turns out that there are substantially different changes required for Cassandra vs DSE, then they should be addressed in separate PRs.
Here is an example manifest that configures the
cassandra
container with a read-only root file system:The
cassandra
goes into a crash loop with this in the log:Environment
v1.8.0
Anything else we need to know?:
We have already implemented a solution (or at least partial) in the k8ssandra Helm chart. Look at the
cassdc.yaml
template here. Here are the highlights:cassandra-config
volume to be used to/etc/cassandra
base-config-init
init container copies out of box configs tocassandra-config
server-config-init
init container (i.e., config builder) runs and writes files to theserver-config
volumecassandra
container mountsserver-config
at/config
cassandra
container mountscassandra-config
at/etc/cassandra
cassandra
container copies files from/config
to/etc/cassandra
Again this what is already done in k8ssandra. We basically need to backport it.
Fixes
┆Issue is synchronized with this Jira Task by Unito
┆epic: Security Phase II
┆friendlyId: K8SSAND-962
┆priority: Medium
The text was updated successfully, but these errors were encountered: