From 89d9079ae99f4e9d8d69ae80572b187ca4a11be6 Mon Sep 17 00:00:00 2001 From: avouacr Date: Tue, 1 Feb 2022 10:47:03 +0000 Subject: [PATCH] improve secret management for external postgre in shiny --- charts/shiny/Chart.yaml | 2 +- charts/shiny/templates/deployment.yaml | 30 +++++++++++++++++++++++--- charts/shiny/values.yaml | 5 ++++- 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/charts/shiny/Chart.yaml b/charts/shiny/Chart.yaml index 4f01737..b7f5f53 100644 --- a/charts/shiny/Chart.yaml +++ b/charts/shiny/Chart.yaml @@ -15,7 +15,7 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.3.1 +version: 0.3.2 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to diff --git a/charts/shiny/templates/deployment.yaml b/charts/shiny/templates/deployment.yaml index 0f2df87..5f1acd8 100644 --- a/charts/shiny/templates/deployment.yaml +++ b/charts/shiny/templates/deployment.yaml @@ -36,10 +36,24 @@ spec: {{- toYaml .Values.securityContext | nindent 12 }} image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" imagePullPolicy: {{ .Values.image.pullPolicy }} - envFrom: + env: {{- if .Values.externalPostgreSQL.enabled }} - - secretRef: - name: {{ .Values.externalPostgreSQL.credentialsSecretName }} + - name: DB_NAME + value: {{ .Values.externalPostgreSQL.database }} + - name: DB_HOST + value: {{ .Values.externalPostgreSQL.hostname }} + - name: DB_PORT + value: {{ .Values.externalPostgreSQL.port | quote }} + - name: DB_USER + valueFrom: + secretKeyRef: + name: {{ .Values.externalPostgreSQL.secretName }} + key: DB_USER + - name: DB_PASSWORD + valueFrom: + secretKeyRef: + name: {{ .Values.externalPostgreSQL.secretName }} + key: DB_PASSWORD {{- end }} ports: - name: http @@ -67,3 +81,13 @@ spec: tolerations: {{- toYaml . | nindent 8 }} {{- end }} + + +conn <- dbConnect( + RPostgres::Postgres(), + dbname = "mydb", + host = "postgresql-701478", + port = 5432, + user = $DB_, + password = "5qntavo5sj1li56e6jqs" +) \ No newline at end of file diff --git a/charts/shiny/values.yaml b/charts/shiny/values.yaml index ae066e3..cb49a89 100644 --- a/charts/shiny/values.yaml +++ b/charts/shiny/values.yaml @@ -76,4 +76,7 @@ affinity: {} externalPostgreSQL: enabled: false - credentialsSecretName: "" + database: "" + hostname: "" + port: "" + secretName: ""