Skip to content
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

Add emptyDir volume for /usr/share/opensearch/config to keystore init container to support readOnlyRootFilesystem: true #951

Open
DrissiReda opened this issue Jan 28, 2025 · 4 comments · May be fixed by #957
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@DrissiReda
Copy link

What is the bug?

I get multiple errors linked to the read-only file system that I don't see how to circumvent

How can one reproduce the bug?

Deploy any cluster with securityContext.readOnlyRootFilesystem set to true.

What is the expected behavior?

I should be able to mount some paths as a R/W emptyDir where OpenSearch can create its files.

However I cannot, for example it tries to create a opensearch.keystore.tmp file in /usr/share/opensearch/config path, but if I mount an emptyDir to that path, I lose default configuration provided by the opensearch image

The complete relevant log:

Likely root cause: java.nio.file.FileSystemException: /usr/share/opensearch/config/opensearch.keystore.tmp: Read-only file system

What is your host/environment?

Kubernetes v1.29.10 rk2
Opensearch version 2.17.0
Operator version 2.7.0

Do you have any screenshots?

Not needed as the problem is straightforward.

Do you have any additional context?

Unrelated maybe but I was unable to change log4j.properties to print all logs to console. If opensearch doesn't need to write logs to file, it doesn't need R/W access to /usr/share/opensearch/logs.

@DrissiReda DrissiReda added bug Something isn't working untriaged Issues that have not yet been triaged labels Jan 28, 2025
@swoehrl-mw
Copy link
Collaborator

Hi @DrissiReda. Does the exception you report happen in the keystore init container or in the main opensearch container?
I would expect in the init container as there the keystore is modified.
If so, we might need to add an extra emptyDir volume just for the init container. I haven't tested it but I would expect there it should not be a problem to mount the volume to /usr/share/opensearch/config.

@DrissiReda
Copy link
Author

DrissiReda commented Jan 31, 2025 via email

@DrissiReda
Copy link
Author

@swoehrl-mw in case you consider doing it. Maybe also think about mentioning usage of keystore init container as a solution for readOnlyRootFilesystem users. And allow for empty keystore[0].keyMappings to avoid opensearch errors on unrecognized keys. This also works for the bootstrap pod by the way.

@swoehrl-mw swoehrl-mw changed the title [BUG] Unable to run OpenSearch Cluster with readOnlyRootFilesystem: true Add emptyDir volume for /usr/share/opensearch/config to keystore init container to support readOnlyRootFilesystem: true Feb 10, 2025
@swoehrl-mw swoehrl-mw added enhancement New feature or request good first issue Good for newcomers and removed bug Something isn't working untriaged Issues that have not yet been triaged labels Feb 10, 2025
@swoehrl-mw
Copy link
Collaborator

Should be rather easy to implement, for anyone who wants to tackle that: Extend the cluster builder to add an emptydir volume and mount it to the keystore init container at /usr/share/opensearch/config.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
Status: 🆕 New
2 participants