ci: run rabbitmq as non-root - #7362
Merged
jennifer-richards merged 4 commits intoApr 24, 2024
Merged
Conversation
Needed since rootfs is now read-only
Rabbitmq needs to be able to write to the fs at /var/lib/rabbitmq. It may be possible to get rid of the initContainer and use fsGroup in the pod securityContext to manage this, but that does not work for the hostVolume mounts I use for dev. The solution here moves the actual mount to the rabbitmq/ directory in the rabbitmq-data volume and uses an initContainer to set the permissions on that. That should work for any volume type.
NGPixel
approved these changes
Apr 24, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Sets securityContexts for the rabbitmq pod so it does not run as root.
This creates a permissions issue with the
rabbitmq-datavolume, which is mounted at/var/lib/rabbitmq. The permissions on that volume require root, at least with thehostPathdriver I use in my dev testing. I tried usingfsGroupin the podseurityContextto fix this but that does not seem to work withhostPath. While it might work for production use, I've instead added aninitContainerto create a subdirectory in therabbitmq-datavolume with the necessary permissions, then mount this viasubPathat/var/lib/rabbitmq.