diff --git a/test/nextcloud/2.3.2/templates/_helpers.tpl b/test/nextcloud/2.3.2/templates/_helpers.tpl index a376df3b00d..004ec38d447 100644 --- a/test/nextcloud/2.3.2/templates/_helpers.tpl +++ b/test/nextcloud/2.3.2/templates/_helpers.tpl @@ -62,6 +62,22 @@ Retrieve host path defined in volume {{- end -}} {{- end -}} +{{/* +Retrieve backup postgresql host path defined in volume +*/}} +{{- define "configuredBackupPostgresHostPath" -}} +{{- $backupVolDict := first .Values.postgresql.backupVolume -}} +{{- $backupVolDict.hostPath -}} +{{- end -}} + +{{/* +Retrieve postgresql data host path defined in volume +*/}} +{{- define "configuredPostgresHostPath" -}} +{{- $dataVolDict := first .Values.postgresql.dataVolume -}} +{{- $dataVolDict.hostPath -}} +{{- end -}} + {{/* Selector labels */}} diff --git a/test/nextcloud/2.3.2/templates/postgres-deployment.yaml b/test/nextcloud/2.3.2/templates/postgres-deployment.yaml new file mode 100644 index 00000000000..ecc6e56a934 --- /dev/null +++ b/test/nextcloud/2.3.2/templates/postgres-deployment.yaml @@ -0,0 +1,51 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ template "nextcloud.fullname" . }}-postgres + labels: + helm.sh/chart: {{ include "nextcloud.chart" . }} + {{- include "nextcloud.postgres.selectorLabels" . | nindent 4 }} + app.kubernetes.io/managed-by: {{ .Release.Service }} + app.kubernetes.io/component: database +spec: + replicas: 1 + strategy: + type: {{ .Values.nextcloud.strategy }} + selector: + matchLabels: + {{- include "nextcloud.postgres.selectorLabels" . | nindent 6 }} + app.kubernetes.io/component: database + template: + metadata: + labels: + {{- include "nextcloud.postgres.selectorLabels" . | nindent 8 }} + app.kubernetes.io/component: database + annotations: + rollme: {{ randAlphaNum 5 | quote }} + spec: + containers: + - name: {{ .Chart.Name }}-postgres + image: "postgres:13.1" + imagePullPolicy: {{ .Values.image.pullPolicy }} + env: + - name: POSTGRES_PASSWORD + valueFrom: + secretKeyRef: + name: db-details + key: db-password + volumeMounts: + - name: postgres-data + mountPath: /var/lib/postgresql/data + - name: postgres-backup + mountPath: /postgres_backups + ports: + - name: postgres-tcp + containerPort: 5432 + protocol: TCP + volumes: + - name: postgres-data + hostPath: + path: {{ template "configuredPostgresHostPath" . }} + - name: postgres-backup + hostPath: + path: {{ template "configuredBackupPostgresHostPath" . }} diff --git a/test/nextcloud/2.3.2/templates/postgres-secret.yaml b/test/nextcloud/2.3.2/templates/postgres-secret.yaml new file mode 100644 index 00000000000..c19e626e65b --- /dev/null +++ b/test/nextcloud/2.3.2/templates/postgres-secret.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: Secret +metadata: + name: db-details +data: + {{- if .Release.IsInstall }} + db-password: {{ randAlphaNum 15 | b64enc | quote }} + {{ else }} + # `index` function is necessary because the property name contains a dash. + # Otherwise (...).data.db_password would have worked too. + db-password: {{ index (lookup "v1" "Secret" .Release.Namespace "db-details").data "db-password" }} + {{ end }}