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

[prometheus-rabbitmq-exporter] Create secret to store credentials when provided #5099

Conversation

jchanam
Copy link
Contributor

@jchanam jchanam commented Dec 26, 2024

What this PR does / why we need it

Connection credentials should be stored securely using secrets. Right now, the chart allows to provide your own secret, but if the credentials are given as values to the chart, they are exposed in the deployment env variables.

This PR adds a new secret, that will be created only if the user or password is provided and if the existing user/password secret is not given.

Special notes for your reviewer

Checklist

  • DCO signed
  • Chart Version bumped
  • Title of the PR starts with chart name (e.g. [prometheus-couchdb-exporter])

Copy link
Member

@desaintmartin desaintmartin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution! This one has been on my list for a while but I never had the time to do it.

@@ -0,0 +1,22 @@
{{- if or (and (.Values.rabbitmq.password) (not .Values.rabbitmq.existingPasswordSecret)) (and (.Values.rabbitmq.user) (not .Values.rabbitmq.existingUserSecret)) }}
Copy link
Member

@desaintmartin desaintmartin Dec 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If .Values.rabbitmq.password is set but .Values.rabbitmq.existingPasswordSecret is set as well, secret will not be created and Pod will never start. We should have a solution. Maybe we should prevent the two being set at the same time, or we align the condition in the two files, or we simply "ignore" the latter like it's done before this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi!

Yes, you're right. If existing password secret is set, then we don't need to create the secret, as we'll be using the one provided in the values.

On that case, the secret where we're reading the value for the env is also the one provided, so I think the pod will be created and running.

This is an example of the env for the deployment on that case:

          env:
            - name: RABBIT_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: "existingsecret"
                  key: "password"
            - name: RABBIT_USER
              valueFrom:
                secretKeyRef:
                  name: "existingsecret"
                  key: "username"
            - name: RABBIT_URL
              value: my-url.com

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

About the options you mentioned, I followed what it was done before. If the existing secret is given, the password or user is ignored and the secret used.

Copy link
Member

@desaintmartin desaintmartin Dec 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am sorry, the diff bugged me, you are right!

@@ -0,0 +1,22 @@
{{- if or (and (.Values.rabbitmq.password) (not .Values.rabbitmq.existingPasswordSecret)) (and (.Values.rabbitmq.user) (not .Values.rabbitmq.existingUserSecret)) }}
Copy link
Member

@desaintmartin desaintmartin Dec 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am sorry, the diff bugged me, you are right!

@desaintmartin desaintmartin merged commit 4dac64a into prometheus-community:main Dec 28, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants