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

Adding templated creds to dbusers #86

Merged
merged 2 commits into from
Dec 20, 2023
Merged

Conversation

allanger
Copy link
Member

@allanger allanger commented Dec 18, 2023

It will close: #80

@allanger allanger self-assigned this Dec 18, 2023
@allanger allanger force-pushed the add-templated-creds-to-dbusers branch 2 times, most recently from f9c816c to aad2200 Compare December 18, 2023 18:21
Now templated credentials can also be added to DbUsers. It's only
allowed to modify a secret that belongs to the User, because configmaps
are always used by Datbases.

Also, I've started using kubehelper to manage DbUser secret, so now it
also supports cleanup and it's updated on each reconciliation
@allanger allanger marked this pull request as ready for review December 18, 2023 18:32
@allanger allanger changed the title WIP: Adding templated creds to dbusers Adding templated creds to dbusers Dec 18, 2023
@allanger
Copy link
Member Author

@mario-steinhoff-gcx
After this is merged and released, you should be able to add

apiVersion: "kinda.rocks/v1beta1"
kind: "DbUser"
metadata:
  name: ~sql_exporter_user~
spec:
  secretName: some-secret
  credentials:
    templates:
      - name: SQLEXPORTER_TARGET_DSN
        template: "{{ .Protocol }}://{{ .Username}}:{{ .Password }}@{{ .Hostname }}:{{ .Port }}/{{ .Database }}?sslmode={{ .ConfigMap \"SSL_MODE\" }}"
        secret: true

To the sql exporter users, then db-operator will add a connection string to the secret, and then you should be able to get them in sql_exporter (if you're on 0.2.4 already) with values like that:

env:
   SQLEXPORTER_TARGET_DSN:
     from:
       kind: Secret
       name: some-secret
       key: SQLEXPORTER_TARGET_DSN:

I'll also ping you in the issue, once it's released

@mario-steinhoff-gcx
Copy link

Awesome, looking forward to the release :)

@allanger allanger force-pushed the add-templated-creds-to-dbusers branch 3 times, most recently from f128cfe to 74bac29 Compare December 20, 2023 12:12
@allanger allanger merged commit 73133b0 into main Dec 20, 2023
20 checks passed
@allanger allanger deleted the add-templated-creds-to-dbusers branch December 20, 2023 14:09
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.

DbUsers should support templated credentials as well
3 participants