From 4a3153b004a485cb33a308e8381e707cc77fb565 Mon Sep 17 00:00:00 2001 From: vixns Date: Mon, 14 Oct 2024 11:36:36 +0200 Subject: [PATCH] external postgres (#2) * external postgres * Rename accidentally misnamed "enable" config --------- Co-authored-by: Gokhan Sari --- charts/listmonk/README.md | 2 ++ charts/listmonk/templates/_helpers.tpl | 8 ++++++++ charts/listmonk/templates/configmap-postgres.yaml | 2 +- charts/listmonk/templates/ingress-listmonk.yaml | 2 +- charts/listmonk/templates/secret-postgres.yaml | 2 ++ charts/listmonk/templates/service-postgres.yaml | 2 ++ charts/listmonk/templates/statefulset-postgres.yaml | 2 ++ charts/listmonk/values.yaml | 6 +++++- 8 files changed, 23 insertions(+), 3 deletions(-) diff --git a/charts/listmonk/README.md b/charts/listmonk/README.md index 230bc91..547e724 100644 --- a/charts/listmonk/README.md +++ b/charts/listmonk/README.md @@ -35,6 +35,8 @@ $ helm uninstall --namespace listmonk listmonk | listmonk.image.repository | string | `"listmonk/listmonk"` | the listmonk image repository | | listmonk.image.tag | string | `"v3.0.0"` | the listmonk image tag | | listmonk.replicas | int | `1` | the number of listmonk deployment replicas | +| postgres.enabled | bool | `true` | enable internal postgres | +| postgres.hostname | string | `""` | external postgres hostname | | postgres.database | string | `"listmonk"` | the postgres database name | | postgres.image.repository | string | `"postgres"` | the postgres image repository | | postgres.image.tag | string | `"16-alpine"` | the postgres image tag | diff --git a/charts/listmonk/templates/_helpers.tpl b/charts/listmonk/templates/_helpers.tpl index 7bfff89..3800640 100644 --- a/charts/listmonk/templates/_helpers.tpl +++ b/charts/listmonk/templates/_helpers.tpl @@ -40,3 +40,11 @@ app.kubernetes.io/instance: {{ .Release.Name }} {{- default "default" .Values.serviceAccount.name }} {{- end }} {{- end }} + +{{- define "listmonk.postgresHostname" -}} +{{- if .Values.postgres.enabled }} +{{- printf "%s-postgres" (include "listmonk.fullname" .) -}} +{{- else }} +{{- required ".Values.postgres.hostname is required when chart's postgres is disabled" .Values.postgres.hostname }} +{{- end }} +{{- end }} diff --git a/charts/listmonk/templates/configmap-postgres.yaml b/charts/listmonk/templates/configmap-postgres.yaml index 8039ae9..61a8d47 100644 --- a/charts/listmonk/templates/configmap-postgres.yaml +++ b/charts/listmonk/templates/configmap-postgres.yaml @@ -6,4 +6,4 @@ metadata: {{- include "listmonk.labels" . | nindent 4 }} data: DATABASE: "{{ .Values.postgres.database}}" - HOST: "{{ include "listmonk.fullname" . }}-postgres" + HOST: {{ include "listmonk.postgresHostname" . | quote }} diff --git a/charts/listmonk/templates/ingress-listmonk.yaml b/charts/listmonk/templates/ingress-listmonk.yaml index 04d0050..bcc3fa3 100644 --- a/charts/listmonk/templates/ingress-listmonk.yaml +++ b/charts/listmonk/templates/ingress-listmonk.yaml @@ -1,4 +1,4 @@ -{{- if .Values.ingress.enable }} +{{- if .Values.ingress.enabled }} apiVersion: networking.k8s.io/v1 kind: Ingress metadata: diff --git a/charts/listmonk/templates/secret-postgres.yaml b/charts/listmonk/templates/secret-postgres.yaml index cb5f12f..78a9be8 100644 --- a/charts/listmonk/templates/secret-postgres.yaml +++ b/charts/listmonk/templates/secret-postgres.yaml @@ -1,3 +1,4 @@ +{{- if .Values.postgres.enabled }} apiVersion: v1 kind: Secret metadata: @@ -7,3 +8,4 @@ metadata: data: PASSWORD: {{ required "A valid .Values.postgres.password is required" .Values.postgres.password | b64enc }} USER: {{ required "A valid .Values.postgres.user is required" .Values.postgres.user | b64enc }} +{{- end }} diff --git a/charts/listmonk/templates/service-postgres.yaml b/charts/listmonk/templates/service-postgres.yaml index 210bd49..47e2efd 100644 --- a/charts/listmonk/templates/service-postgres.yaml +++ b/charts/listmonk/templates/service-postgres.yaml @@ -1,3 +1,4 @@ +{{- if .Values.postgres.enabled }} apiVersion: v1 kind: Service metadata: @@ -14,3 +15,4 @@ spec: port: 5432 protocol: TCP targetPort: 5432 +{{- end }} diff --git a/charts/listmonk/templates/statefulset-postgres.yaml b/charts/listmonk/templates/statefulset-postgres.yaml index 9df7061..d9f2edb 100644 --- a/charts/listmonk/templates/statefulset-postgres.yaml +++ b/charts/listmonk/templates/statefulset-postgres.yaml @@ -1,3 +1,4 @@ +{{- if .Values.postgres.enabled }} apiVersion: apps/v1 kind: StatefulSet metadata: @@ -60,3 +61,4 @@ spec: requests: storage: 10Gi volumeMode: Filesystem +{{- end }} diff --git a/charts/listmonk/values.yaml b/charts/listmonk/values.yaml index 8fc6f41..40388fa 100644 --- a/charts/listmonk/values.yaml +++ b/charts/listmonk/values.yaml @@ -2,7 +2,7 @@ ingress: # -- annotations for the ingress annotations: {} # -- enable the ingress - enable: false + enabled: false # -- host for the ingress host: listmonk.local # -- tls configuration for the ingress @@ -21,6 +21,10 @@ listmonk: # -- the number of listmonk deployment replicas replicas: 1 postgres: + # -- enable postgres + enabled: true + # -- when not enabled, the external postgress service hostname is required + hostname: "" # -- the postgres database name database: listmonk image: