Skip to content

Use DB connections provided via environment variables or use envs in config #590

Closed Answered by MustDie95
MustDie95 asked this question in Q&A
Discussion options

You must be logged in to vote

Looks like I finally solved this puzzle

Thanks to K8s docs (https://kubernetes.io/docs/tasks/inject-data-application/define-interdependent-environment-variables/)

Have renamed PG_DSN variable to PG_XDSN and use correct brackets and voula.. it works as desired..

  PG_XDSN:
    value: postgresql://$(PG_USER):$(PG_PASSWORD)@$(PG_HOST):5432

Now envs in POD's yaml are rendered in correct order:

     env:
        - name: PG_HOST
          value: db-cluster
        - name: PG_PASSWORD
          valueFrom:
            secretKeyRef:
              name: blackbox.db-cluster.credentials.postgresql.acid.zalan.do
              key: password
        - name: PG_USER
          valueFrom:
            secr…

Replies: 5 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@burningalchemist
Comment options

@MustDie95
Comment options

Answer selected by burningalchemist
@burningalchemist
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #586 on September 06, 2024 09:31.