-
Notifications
You must be signed in to change notification settings - Fork 432
docker-entrypoint.sh fails if config file is mounted as read-only #368
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
Comments
This is a pretty common use-case given that as of Kubernetes v1.9.4 configMaps are mounted as read-only. Fixes docker-library#368
Duplicate of #292. See specifically #292 (comment) |
Thanks for the reference! I guess the suggestion in #292 (comment) would work indeed. However, may I ask you to consider the following. The fact that this issue and the previous one (#292) both exist in the first place should make clear that this is a pretty common use-case and it isn't quite obvious to people why they are seeing these failures. Asking everyone that runs into this to read and understand the entrypoint script or look at the issues in this repo doesn't seem very user-friendly and a bit of a waste of our collective time. |
The limitations of Kubernetes' configmaps and how they convey those is really a user-environment issue and not something we can make compatible with the typical Docker functionality of modifying a config file with environment variables. Potentially you could extend the entrypoint functionality for mounting it in a separate location then copying it over with the copy having appropriate permissions. Since when you pass an environment variable it will modify the config file. And if the permissions are non-permissive then you get a descriptive error of The alternative with Kubernetes is to use an init container to mount the config, or supply the full config without any environment variables that the entrypoint interprets, so that way the config's permissions can be read-only without error. Variables like |
All of that could be solved if the file replacement didn't happen in original config directory. Just letting specify writable location for config to be copied to would be enough to solve the issue. |
@tianon @yosifkit we keep seeing this issue pop up for RabbitMQ users deploying to Kubernetes. In fact, it comes up every few days and it's particularly frustrating to troubleshoot if you don't know where to start. Would you please reconsider the decision to label this as a "question" and consider @st3v's ideas or at least making #292 (comment) (a user-provided config file) to be the first option documentation recommends? It would save RabbitMQ users and the core team a lot of frustration. Thank you. |
I'm not sure if dropping support for some environment variables this image invents on top of RabbitMQ would be an option; the culture of "env variables for everything" is counterproductive IMO. RabbitMQ does not use environment variables heavily (they mostly control locations of things, which is reasonable), and in particular does not support or recommend them for pre-seeding users at deployment time. |
#369 seems like a reasonable approach to me: if the directory is not writeable, move the config file to another directory and point |
@michaelklishin, making a copy doesn't seem unreasonable, since that is what we already do to ssl certificate files: Lines 91 to 101 in 88ac0b2
I think we'll also need to check if the config file is a mount since the permissions won't really indicate whether a I'd be fairly tempted to drop all the environment variables from the image in the next major release (like |
Background
When deploying RabbitMQ to Kubernetes it is pretty common to mount a
configMap
that contains arabbitmq.conf
file inside the container. As of Kubernetes 1.9.4configMaps
are always mounted as read-only (see changelog for K8s 1.9.4). That change was made to address a CVE. Now the problem is thatdocker-entrypoint.sh
tries to write to the rabbitmq config whenever certain environment variables are set in the container (e.g.RABBITMQ_DEFAULT_USER
). Obviously, this fails when the file gets mounted as read-only.Happy Case 🙂
Kubernetes pods start and run perfectly fine as long as I don't set one of the magic env vars that causes
docker-entrypoint.sh
to write to the mounted/etc/rabbitmq/rabbitmq.conf
.Sad Case 😢
Pods don't start as soon as I set
RABBITMQ_DEFAULT_USER
. The pod logs show thatsed
couldn't write to the mounted directory.Difference between both cases
Workaround
initContainer
to the pod that copies the config file to a write-able locationExample: https://gist.github.com/st3v/ffefe94c84c196d90a420bb561f2878f#file-repro_workaround-yaml
Desired Behavior
I'd argue that the RabbitMQ docker image should add out-of-the-box support for read-only config files. The workaround using an
initContainer
is kinda hacky and shouldn't be necessary for something that is arguably a pretty common use case given the Kubernetes behavior described above.Resources
YAML files used above: https://gist.github.com/st3v/ffefe94c84c196d90a420bb561f2878f
The text was updated successfully, but these errors were encountered: