Skip to content

Commit

Permalink
improve secret management for external postgre in shiny
Browse files Browse the repository at this point in the history
  • Loading branch information
avouacr committed Feb 1, 2022
1 parent 811246e commit 89d9079
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 5 deletions.
2 changes: 1 addition & 1 deletion charts/shiny/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 27 additions & 3 deletions charts/shiny/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
)
5 changes: 4 additions & 1 deletion charts/shiny/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,7 @@ affinity: {}

externalPostgreSQL:
enabled: false
credentialsSecretName: ""
database: ""
hostname: ""
port: ""
secretName: ""

0 comments on commit 89d9079

Please sign in to comment.