-
Notifications
You must be signed in to change notification settings - Fork 276
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
Support Vault via vault-k8s #846
Conversation
since it shouldn't be readable by everyone. Before this commit: ls -al /etc/rabbitmq/conf.d/ drwxrwsrwt 2 root rabbitmq 100 Sep 7 14:52 . drwxrwxrwx 1 rabbitmq rabbitmq 4096 Sep 7 14:30 .. -rw-r--r-- 1 root rabbitmq 604 Sep 7 14:29 10-operatorDefaults.conf -rw-r--r-- 1 _apt rabbitmq 45 Sep 7 14:52 11-default_user.conf -rw-r--r-- 1 root rabbitmq 51 Sep 7 14:29 90-userDefinedConfiguration.conf After this commit: ls -al /etc/rabbitmq/conf.d/ drwxrwsrwt 2 root rabbitmq 100 Sep 8 07:19 . drwxrwxrwx 1 rabbitmq rabbitmq 4096 Sep 8 07:19 .. -rw-r--r-- 1 root rabbitmq 604 Sep 8 07:18 10-operatorDefaults.conf -rw-r----- 1 rabbitmq rabbitmq 45 Sep 8 07:19 11-default_user.conf -rw-r--r-- 1 root rabbitmq 51 Sep 8 07:18 90-userDefinedConfiguration.conf
because this is needed when inter-node TLS is enabled or when scraping metrics via TLS. Although each RabbitMQ pod will request its own certificate, we still include all pod hostnames into every certificate because the index will only be known at runtime (not cluster-operator deploy time) and we can't use K8s downward API here since the labels must be set correctly when the vault-agent init container runs before all other containers.
Add unit tests for vault annotations TODO: add unit tests for vault commands and mounts
if default user secret is stored in Vault
Before this commit: 2021-09-09T13:27:27.312Z [INFO] (runner) rendered "(dynamic)" => "/etc/rabbitmq-tls//tls.key" 2021-09-09T13:27:27.313Z [INFO] (runner) rendered "(dynamic)" => "/etc/rabbitmq-tls//tls.crt"
Pending: Unit test
and fix mountpath
since it serves as kind of docs for our uses to give a high level idea of what needs to be set up on Vault side. Rename some fields to be more succinct.
Some K8s clusters (e.g. kind) require to set the issuer. Do not set the issuer on GKE.
@twhite0 thank you for your followups, these are excellent questions.
We set a PodSecurityContext to run as user 999 and FSGroup 999:
We just removed the other container SecurityContext via 6b529d9 since they are indeed not needed because they were only setting The driver to set the PodSecurityContext is to run processes as RabbitMQ user (as opposed to running as root user). For OpenShift, this is not needed since the runtime will assign arbitrary user IDs to the containers as documented in https://www.rabbitmq.com/kubernetes/operator/using-on-openshift.html#arbitrary-user-ids.
You can now set arbitrary Vault annotations as documented in cluster-operator/docs/examples/vault-default-user/rabbitmq.yaml Lines 10 to 13 in 2f0e49c
|
@ansd: Thanks for the response and quick pivots as a result of my questions. We were able to pull the latest changes and see great results.
Let us know if there's anything else you'd like us to test or comment on. |
Thanks a lot @twhite0 for your feedback. That's perfect! @MarcialRosales had some good refactoring suggestions yesterday, he will change Vault field names slightly. Thereafter we should be ready to merge. |
Vault attributes renaming: PathDefaultUser -> DefaultUserPath PathCertificate -> PKIIssuerPath Password rotation enabled by default: By default, the cluster operator deploys a sidecar container with a default image name It is possible to override the image by setting `DefaultUserUpdaterImage` Removed SecretBackend `CredentialUpdaterImage` in favor of having a dedicated image to control how to rotate passwords when Vault is enabled
and allow to disable the sidecar container by setting image name to empty string.
We noticed the credit: @ssheth1 |
…er resource if default user credentials come from Vault
to rabbitmq/default-user-credential-updater to allow for easier and independant versioning from cluster-operator. We do not want to have the admin-password-updater image the same version as the cluster-operator image.
so that new repo name matches image name, container name, and entrypoint.
The attributes were vault.defaultUserPath and vault.tls.pkiIssuerPath
This closes #822, #823, #824.
Before this PR, the cluster-operator was always creating the credentials of the default (admin) user putting them into a K8s Secret object. TLS is supported by the user providing a K8s Secret object containing certificate and private key.
However, some users want to store credentials outside of K8s in external secret stores such as HashiCorp Vault, AWS Secrets Manager, Google Secrets Manager or Azure Key Vault. Benefits of doing so include:
As explained in this KubeCon talk there 4 different approaches in K8s to consume external secrets:
In this PR, we take the 3rd approach (
Sidecar + MutatingWebhookConfiguration
) integrating with Vault using vault-k8s. Ifspec.secretBackend.vault
is configured in the RabbimqCluster CRD, no K8s Secret will be created for the default user credentials. Instead a Vault init container + sidecar fetch credentials from Vault.In future, we might (no promises) support approaches
2. Controller to mirrors secrets in K8s
as for example requested in #840 and4. Secrets Store CSI Driver
. The latter seems to be the future proof K8s native way of fetching external secrets.This PR adds support for 3 features:
/etc/rabbitmq/conf.d/11-default_user.conf
file. However, RabbitMQ cannot pick up config file changes on the fly. Therefore, some component need to update the password on the RabbitMQ server. The Vault sidecar container does not seem to contain the tools to HTTP PUT to the RabbitMQ Management API or tokubectl exec
into the RabbitMQ container. Since we do not want to change the default Vault image, a 2nd side car can optionally be deployed. It contains a single Go binary that watches11-default_user.conf
for changes. If a new password is detected, it HTTP PUT to the RabbitMQ management API updating the password server side and copies the password into/var/lib/rabbitmq/.rabbitmqadmin.conf
to be used for therabbitmqadmin
CLI. Username rotation is not supported./etc/rabbitmq-tls/
where it will be picked up on-the-fly by the Erlang VM without the need to restart the pod.No changes are done to the Erlang cookie: it will still be created by the cluster-operator and stored in a K8s Secret.
Tests:
admin-password-updater
sidecar container.docs/examples/vault-default-user
anddocs/examples/vault-tls
directories covering the above 3 features and will be run in our Concourse pipeline. Thesetup.sh
scripts give users a high level idea of what needs to be setup on Vault server side (although the examples use only Vault server dev mode).Most of the work in this PR was done by @MarcialRosales 🙌
This PR is a draft because the following TODOs are left:
docs/examples/vault-*/
directories.