Skip to content

Commit 87c08e1

Browse files
committed
feat: add support for external postgres secrets in listmonk chart
- Add helper templates for postgres secret name and key resolution - Support existing secrets via existingSecret and secretKey values - Restructure values under listmonk namespace for better organization - Bump chart version to 0.5.0
1 parent e122adc commit 87c08e1

File tree

7 files changed

+60
-39
lines changed

7 files changed

+60
-39
lines changed

charts/listmonk/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ appVersion: "5.1.0"
33
description: High performance, self-hosted, newsletter and mailing list manager with a modern dashboard.
44
name: listmonk
55
type: application
6-
version: 0.4.0
6+
version: 0.5.0
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{{/*
2+
Get the postgres secret name
3+
*/}}
4+
{{- define "listmonk.postgresSecretName" -}}
5+
{{- if .Values.postgres.existingSecret -}}
6+
{{- .Values.postgres.existingSecret -}}
7+
{{- else -}}
8+
{{- .Release.Name }}-postgres-secret
9+
{{- end -}}
10+
{{- end -}}
11+
12+
{{/*
13+
Get the postgres secret key
14+
*/}}
15+
{{- define "listmonk.postgresSecretKey" -}}
16+
{{- if .Values.postgres.secretKey -}}
17+
{{- .Values.postgres.secretKey -}}
18+
{{- else -}}
19+
postgres-password
20+
{{- end -}}
21+
{{- end -}}

charts/listmonk/templates/deployment.yaml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ metadata:
66
app: {{ .Release.Name }}-listmonk
77
app.kubernetes.io/component: listmonk
88
spec:
9-
replicas: {{ .Values.replicas }}
9+
replicas: {{ .Values.listmonk.replicas }}
1010
selector:
1111
matchLabels:
1212
app.kubernetes.io/component: listmonk
@@ -42,8 +42,8 @@ spec:
4242
- name: PGPASSWORD
4343
valueFrom:
4444
secretKeyRef:
45-
name: {{ .Release.Name }}-postgres-secret
46-
key: postgres-password
45+
name: {{ include "listmonk.postgresSecretName" . }}
46+
key: {{ include "listmonk.postgresSecretKey" . }}
4747
- name: PGSSLMODE
4848
value: "disable"
4949
- name: check-db-tables
@@ -63,15 +63,15 @@ spec:
6363
- name: PGPASSWORD
6464
valueFrom:
6565
secretKeyRef:
66-
name: {{ .Release.Name }}-postgres-secret
67-
key: postgres-password
66+
name: {{ include "listmonk.postgresSecretName" . }}
67+
key: {{ include "listmonk.postgresSecretKey" . }}
6868
- name: PGSSLMODE
6969
value: "disable"
7070
volumeMounts:
7171
- name: init-flag
7272
mountPath: /tmp
7373
- name: db-init
74-
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
74+
image: "{{ .Values.listmonk.image.repository }}:{{ .Values.listmonk.image.tag }}"
7575
imagePullPolicy: IfNotPresent
7676
command: ["/bin/sh", "-c"]
7777
args:
@@ -97,8 +97,8 @@ spec:
9797
- name: LISTMONK_db__password
9898
valueFrom:
9999
secretKeyRef:
100-
name: {{ .Release.Name }}-postgres-secret
101-
key: postgres-password
100+
name: {{ include "listmonk.postgresSecretName" . }}
101+
key: {{ include "listmonk.postgresSecretKey" . }}
102102
- name: LISTMONK_db__database
103103
value: "{{ .Values.postgres.database }}"
104104
- name: LISTMONK_db__ssl_mode
@@ -108,7 +108,7 @@ spec:
108108
mountPath: /tmp
109109
containers:
110110
- name: {{ .Release.Name }}-listmonk
111-
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
111+
image: "{{ .Values.listmonk.image.repository }}:{{ .Values.listmonk.image.tag }}"
112112
imagePullPolicy: IfNotPresent
113113
command: ["./listmonk", "--config", "/listmonk/config/app-config.toml"]
114114
env:
@@ -128,8 +128,8 @@ spec:
128128
- name: LISTMONK_db__password
129129
valueFrom:
130130
secretKeyRef:
131-
name: {{ .Release.Name }}-postgres-secret
132-
key: postgres-password
131+
name: {{ include "listmonk.postgresSecretName" . }}
132+
key: {{ include "listmonk.postgresSecretKey" . }}
133133
- name: LISTMONK_db__database
134134
value: "{{ .Values.postgres.database }}"
135135
- name: LISTMONK_db__ssl_mode
@@ -158,7 +158,7 @@ spec:
158158
- name: config
159159
mountPath: /listmonk/config
160160
resources:
161-
{{- toYaml .Values.resources | nindent 10 }}
161+
{{- toYaml .Values.listmonk.resources | nindent 10 }}
162162
volumes:
163163
- name: uploads
164164
persistentVolumeClaim:

charts/listmonk/templates/postgres-deployment.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ spec:
2828
- name: POSTGRES_PASSWORD
2929
valueFrom:
3030
secretKeyRef:
31-
name: {{ .Release.Name }}-postgres-secret
32-
key: postgres-password
31+
name: {{ include "listmonk.postgresSecretName" . }}
32+
key: {{ include "listmonk.postgresSecretKey" . }}
3333
- name: POSTGRES_DB
3434
value: "{{ .Values.postgres.database }}"
3535
- name: PGDATA

charts/listmonk/templates/pvc.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ spec:
77
- ReadWriteOnce
88
resources:
99
requests:
10-
storage: {{ .Values.storage.uploadsSize | default "5Gi" }}
10+
storage: {{ .Values.listmonk.storage.uploadsSize | default "5Gi" }}
1111
---
1212
apiVersion: v1
1313
kind: PersistentVolumeClaim
@@ -18,4 +18,4 @@ spec:
1818
- ReadWriteOnce
1919
resources:
2020
requests:
21-
storage: {{ .Values.storage.staticSize | default "1Gi" }}
21+
storage: {{ .Values.listmonk.storage.staticSize | default "1Gi" }}
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1+
{{- if not .Values.postgres.existingSecret }}
12
apiVersion: v1
23
kind: Secret
34
metadata:
45
name: {{ .Release.Name }}-postgres-secret
56
type: Opaque
67
data:
7-
{{- if .Values.postgres.existingSecret }}
8-
postgres-password: {{ .Values.postgres.existingSecret | b64enc | quote }}
9-
{{- else }}
108
postgres-password: {{ .Values.postgres.password | b64enc | quote }}
11-
{{- end }}
9+
{{- end }}

charts/listmonk/values.yaml

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
commonAnnotations: {}
1+
hcommonAnnotations: {}
22
podAnnotations: {}
33
podLabels: {}
44
extraInitContainers: {}
@@ -18,24 +18,24 @@ ingress:
1818
service:
1919
type: ClusterIP
2020
annotations: {}
21+
listmonk:
22+
# -- The listmonk image configuration
23+
image:
24+
# -- the listmonk image repository
25+
repository: listmonk/listmonk
26+
# -- the listmonk image tag
27+
tag: v5.1.0
2128

22-
# -- The listmonk image configuration
23-
image:
24-
# -- the listmonk image repository
25-
repository: listmonk/listmonk
26-
# -- the listmonk image tag
27-
tag: v5.1.0
28-
29-
# -- the number of listmonk deployment replicas
30-
replicas: 1
29+
# -- the number of listmonk deployment replicas
30+
replicas: 1
3131

32-
# -- resources for the listmonk deployment
33-
resources: {}
32+
# -- resources for the listmonk deployment
33+
resources: {}
3434

35-
# -- Storage configuration for listmonk
36-
storage:
37-
uploadsSize: "5Gi"
38-
staticSize: "1Gi"
35+
# -- Storage configuration for listmonk
36+
storage:
37+
uploadsSize: "5Gi"
38+
staticSize: "1Gi"
3939

4040
postgres:
4141
# -- the postgres database name
@@ -44,9 +44,11 @@ postgres:
4444
enabled: true
4545
# -- when not enabled, the external postgres service hostname is required
4646
hostname: ""
47-
# -- existing secret name containing postgres password
47+
# -- existing secret name containing postgres password (if set, password field is ignored and no secret is created)
4848
existingSecret: ""
49-
# -- the postgres password
49+
# -- key in existing secret containing the password (defaults to postgres-password)
50+
secretKey: ""
51+
# -- the postgres password (ignored if existingSecret is set)
5052
password: "listmonk"
5153
# -- the postgres username
5254
user: "listmonk"

0 commit comments

Comments
 (0)