Skip to content

Commit 387b989

Browse files
committed
Add Secret for database access
1 parent 0f2136d commit 387b989

4 files changed

Lines changed: 28 additions & 4 deletions

File tree

charts/wordsmith-api/templates/deployment.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,19 @@ spec:
2121
- name: {{ .Chart.Name }}
2222
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
2323
imagePullPolicy: {{ .Values.image.pullPolicy }}
24+
env:
25+
- name: "DATABASE_URL"
26+
value: {{ .Values.database.url }}
27+
- name: "USERNAME"
28+
valueFrom:
29+
secretKeyRef:
30+
key: username
31+
name: {{ .Release.Name }}-auth
32+
- name: "PASSWORD"
33+
valueFrom:
34+
secretKeyRef:
35+
key: password
36+
name: {{ .Release.Name }}-auth
2437
ports:
2538
- containerPort: {{ .Values.service.internalPort }}
2639
livenessProbe:
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
apiVersion: v1
2+
kind: Secret
3+
metadata:
4+
name: {{ .Release.Name }}-auth
5+
data:
6+
password: {{ .Values.database.password }}
7+
username: {{ .Values.database.username }}

charts/wordsmith-api/values.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,8 @@ terminationGracePeriodSeconds: 10
3232
ingress:
3333
hosts:
3434
- api.preview.wordsmith.beescloud.com
35-
annotations:
35+
annotations:
36+
database:
37+
url: jdbc:postgresql://wordsmith-staging.ca3tifbqfpuf.us-east-1.rds.amazonaws.com:5432/wordsmith
38+
username: root
39+
password: password
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
spring.datasource.url=jdbc:postgresql://host:port/database
2-
spring.datasource.username=dbuser
3-
spring.datasource.password=dbpass
1+
spring.datasource.url=${DATABASE_URL:default_url}
2+
spring.datasource.username=${SECRETS_DB_USER:demo}
3+
spring.datasource.password=${SECRETS_DB_PASSWORD:demo}
44
spring.datasource.driver-class-name=org.postgresql.Driver

0 commit comments

Comments
 (0)