diff --git a/charts/nextcloud/templates/_helpers.tpl b/charts/nextcloud/templates/_helpers.tpl index 5efea5d1..59e9cfbd 100644 --- a/charts/nextcloud/templates/_helpers.tpl +++ b/charts/nextcloud/templates/_helpers.tpl @@ -64,11 +64,7 @@ Create image name that is used in the deployment {{/* Create environment variables used to configure the nextcloud container as well as the cron sidecar container. */}} -{{- define "nextcloud.env" -}} -{{- if .Values.phpClientHttpsFix.enabled }} -- name: OVERWRITEPROTOCOL - value: {{ .Values.phpClientHttpsFix.protocol | quote }} -{{- end }} +{{- define "nextcloud.env.database" -}} {{- if .Values.internalDatabase.enabled }} - name: SQLITE_DATABASE value: {{ .Values.internalDatabase.name | quote }} @@ -87,6 +83,8 @@ Create environment variables used to configure the nextcloud container as well a secretKeyRef: name: {{ .Values.externalDatabase.existingSecret.secretName | default (printf "%s-db" .Release.Name) }} key: {{ .Values.externalDatabase.existingSecret.passwordKey }} +- name: DATABASE_URL + value: "mysql://$(MYSQL_USER):$(MYSQL_PASSWORD)@$(MYSQL_HOST)/$(MYSQL_DATABASE)" {{- else if .Values.postgresql.enabled }} - name: POSTGRES_HOST value: {{ template "postgresql.v1.primary.fullname" .Subcharts.postgresql }} @@ -106,6 +104,8 @@ Create environment variables used to configure the nextcloud container as well a secretKeyRef: name: {{ .Values.externalDatabase.existingSecret.secretName | default (printf "%s-db" .Release.Name) }} key: {{ .Values.externalDatabase.existingSecret.passwordKey }} +- name: DATABASE_URL + value: "postgres://$(POSTGRES_USER):$(POSTGRES_PASSWORD)@$(POSTGRES_HOST)/$(POSTGRES_DB)" {{- else }} {{- if eq .Values.externalDatabase.type "postgresql" }} - name: POSTGRES_HOST @@ -136,6 +136,8 @@ Create environment variables used to configure the nextcloud container as well a secretKeyRef: name: {{ .Values.externalDatabase.existingSecret.secretName | default (printf "%s-db" .Release.Name) }} key: {{ .Values.externalDatabase.existingSecret.passwordKey }} +- name: DATABASE_URL + value: "postgres://$(POSTGRES_USER):$(POSTGRES_PASSWORD)@$(POSTGRES_HOST)/$(POSTGRES_DB)" {{- else }} - name: MYSQL_HOST {{- if .Values.externalDatabase.existingSecret.hostKey }} @@ -166,7 +168,44 @@ Create environment variables used to configure the nextcloud container as well a name: {{ .Values.externalDatabase.existingSecret.secretName | default (printf "%s-db" .Release.Name) }} key: {{ .Values.externalDatabase.existingSecret.passwordKey }} {{- end }} +- name: DATABASE_URL + value: "mysql://$(MYSQL_USER):$(MYSQL_PASSWORD)@$(MYSQL_HOST)/$(MYSQL_DATABASE)" +{{- end }} +{{- end }} + +{{/* +Redis env vars +*/}} +{{- define "nextcloud.env.redis" -}} +- name: REDIS_HOST + value: {{ template "nextcloud.redis.fullname" . }}-master +- name: REDIS_HOST_PORT + value: {{ .Values.redis.master.service.ports.redis | quote }} +{{- if .Values.redis.auth.enabled }} +{{- if and .Values.redis.auth.existingSecret .Values.redis.auth.existingSecretPasswordKey }} +- name: REDIS_HOST_PASSWORD + valueFrom: + secretKeyRef: + name: {{ .Values.redis.auth.existingSecret }} + key: {{ .Values.redis.auth.existingSecretPasswordKey }} +{{- else }} +- name: REDIS_HOST_PASSWORD + value: {{ .Values.redis.auth.password }} +{{- end }} +- name: REDIS_URL + value: "redis://:$(REDIS_HOST_PASSWORD)@$(REDIS_HOST):$(REDIS_HOST_PORT)" +{{- else }} +- name: REDIS_URL + value: "redis://$(REDIS_HOST):$(REDIS_HOST_PORT)" {{- end }} +{{- end }} + +{{- define "nextcloud.env" -}} +{{- if .Values.phpClientHttpsFix.enabled }} +- name: OVERWRITEPROTOCOL + value: {{ .Values.phpClientHttpsFix.protocol | quote }} +{{- end }} +{{- template "nextcloud.env.database" . }} - name: NEXTCLOUD_ADMIN_USER valueFrom: secretKeyRef: @@ -216,26 +255,8 @@ Create environment variables used to configure the nextcloud container as well a name: {{ .Values.nextcloud.existingSecret.secretName | default (include "nextcloud.fullname" .) }} key: {{ .Values.nextcloud.existingSecret.smtpPasswordKey }} {{- end }} -{{/* -Redis env vars -*/}} {{- if .Values.redis.enabled }} -- name: REDIS_HOST - value: {{ template "nextcloud.redis.fullname" . }}-master -- name: REDIS_HOST_PORT - value: {{ .Values.redis.master.service.ports.redis | quote }} -{{- if .Values.redis.auth.enabled }} -{{- if and .Values.redis.auth.existingSecret .Values.redis.auth.existingSecretPasswordKey }} -- name: REDIS_HOST_PASSWORD - valueFrom: - secretKeyRef: - name: {{ .Values.redis.auth.existingSecret }} - key: {{ .Values.redis.auth.existingSecretPasswordKey }} -{{- else }} -- name: REDIS_HOST_PASSWORD - value: {{ .Values.redis.auth.password }} -{{- end }} -{{- end }} +{{ template "nextcloud.env.redis" . }} {{- end }}{{/* end if redis.enabled */}} {{/* S3 as primary object store env vars @@ -342,7 +363,6 @@ Swift as primary object store env vars {{- end }} {{- end -}} - {{/* Create volume mounts for the nextcloud container as well as the cron sidecar container. */}} diff --git a/charts/nextcloud/templates/db-secret.yaml b/charts/nextcloud/templates/db-secret.yaml index 66691342..02656fb7 100644 --- a/charts/nextcloud/templates/db-secret.yaml +++ b/charts/nextcloud/templates/db-secret.yaml @@ -16,19 +16,16 @@ data: {{- with .Values.mariadb.auth }} db-username: {{ .username | b64enc | quote }} db-password: {{ .password | b64enc | quote }} - db-url: {{ printf "mysql://%s:%s@%s/%s" .username .password (include "mariadb.primary.fullname" $.Subcharts.mariadb) .database | b64enc | quote }} {{- end }} {{- else if .Values.postgresql.enabled }} {{- with .Values.postgresql.global.postgresql.auth }} db-username: {{ .username | b64enc | quote }} db-password: {{ .password | b64enc | quote }} - db-url: {{ printf "postgres://%s:%s@%s/%s" .username .password (include "postgresql.v1.primary.fullname" $.Subcharts.postgresql) .database | b64enc | quote }} {{- end }} {{- else }} {{- with .Values.externalDatabase }} db-username: {{ .user | b64enc | quote }} db-password: {{ .password | b64enc | quote }} - db-url: {{ printf "%s://%s:%s@%s/%s" .type .user .password .host .database | b64enc | quote }} {{- end }} {{- end }} {{- end }} diff --git a/charts/nextcloud/templates/deployment.yaml b/charts/nextcloud/templates/deployment.yaml index 5e1d9d57..cd27f335 100644 --- a/charts/nextcloud/templates/deployment.yaml +++ b/charts/nextcloud/templates/deployment.yaml @@ -300,7 +300,7 @@ spec: {{- end }} {{- if .Values.mariadb.enabled }} - name: mariadb-isalive - image: {{ .Values.mariadb.image.registry | default "docker.io" }}/{{ .Values.mariadb.image.repository }}:{{ .Values.mariadb.image.tag }} + image: {{ .Values.mariadb.image.registry }}/{{ .Values.mariadb.image.repository }}:{{ .Values.mariadb.image.tag }} {{- with .Values.nextcloud.mariaDbInitContainer }} resources: {{- toYaml .resources | nindent 12 }} @@ -308,23 +308,14 @@ spec: {{- toYaml .securityContext | nindent 12 }} {{- end }} env: - - name: MYSQL_USER - valueFrom: - secretKeyRef: - name: {{ .Values.externalDatabase.existingSecret.secretName | default (printf "%s-db" .Release.Name) }} - key: {{ .Values.externalDatabase.existingSecret.usernameKey }} - - name: MYSQL_PASSWORD - valueFrom: - secretKeyRef: - name: {{ .Values.externalDatabase.existingSecret.secretName | default (printf "%s-db" .Release.Name) }} - key: {{ .Values.externalDatabase.existingSecret.passwordKey }} + {{- include "nextcloud.env.database" . | nindent 12 }} command: - "sh" - "-c" - - {{ printf "until mysql --host=%s-mariadb --user=${MYSQL_USER} --password=${MYSQL_PASSWORD} --execute=\"SELECT 1;\"; do echo waiting for mysql; sleep 2; done;" .Release.Name }} + - {{ printf "until mysql --host=${MYSQL_HOST} --user=${MYSQL_USER} --password=${MYSQL_PASSWORD} --execute=\"SELECT 1;\"; do echo waiting for mysql; sleep 2; done;" }} {{- else if .Values.postgresql.enabled }} - name: postgresql-isready - image: {{ .Values.postgresql.image.registry | default "docker.io" }}/{{ .Values.postgresql.image.repository }}:{{ .Values.postgresql.image.tag }} + image: {{ .Values.postgresql.image.registry }}/{{ .Values.postgresql.image.repository }}:{{ .Values.postgresql.image.tag }} {{- with .Values.nextcloud.postgreSqlInitContainer }} resources: {{- toYaml .resources | nindent 12 }} @@ -332,13 +323,7 @@ spec: {{- toYaml .securityContext | nindent 12 }} {{- end }} env: - - name: POSTGRES_USER - valueFrom: - secretKeyRef: - name: {{ .Values.externalDatabase.existingSecret.secretName | default (printf "%s-db" .Release.Name) }} - key: {{ .Values.externalDatabase.existingSecret.usernameKey }} - - name: POSTGRES_HOST - value: {{ template "postgresql.v1.primary.fullname" .Subcharts.postgresql }} + {{- include "nextcloud.env.database" . | nindent 12 }} command: - "sh" - "-c" diff --git a/charts/nextcloud/templates/notify_push/deployment.yaml b/charts/nextcloud/templates/notify_push/deployment.yaml index 5b93ddc0..5f1da9a2 100644 --- a/charts/nextcloud/templates/notify_push/deployment.yaml +++ b/charts/nextcloud/templates/notify_push/deployment.yaml @@ -46,13 +46,13 @@ spec: value: "7867" - name: METRICS_PORT value: "9867" - - name: DATABASE_URL - valueFrom: - secretKeyRef: - name: {{ .Values.externalDatabase.existingSecret.secretName | default (printf "%s-db" .Release.Name) }} - key: {{ .Values.externalDatabase.existingSecret.databaseURLKey }} - - name: REDIS_URL - value: "redis://{{ if .Values.redis.auth.enabled }}:{{ .Values.redis.auth.password }}@{{ end }}{{ template "nextcloud.redis.fullname" . }}-master:{{ .Values.redis.master.service.ports.redis }}" + {{- include "nextcloud.env.database" . | nindent 12 }} + {{- with .Values.notifyPush.redisURLEnv }} + - name: "REDIS_URL" + {{- toYaml . | nindent 14 }} + {{- else }} + {{- include "nextcloud.env.redis" . | nindent 12 }} + {{- end }} - name: NEXTCLOUD_URL # deployment.namespace.svc.cluster.local value: "http{{ if .Values.notifyPush.https }}s{{ end }}://{{ template "nextcloud.fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local:{{ .Values.service.port }}" ports: diff --git a/charts/nextcloud/test-values/notify_push.yaml b/charts/nextcloud/test-values/notify_push.yaml index 99dda486..65a11e71 100644 --- a/charts/nextcloud/test-values/notify_push.yaml +++ b/charts/nextcloud/test-values/notify_push.yaml @@ -1,2 +1,5 @@ +redis: + enabled: true + notifyPush: enabled: true diff --git a/charts/nextcloud/values.yaml b/charts/nextcloud/values.yaml index ee8f94e7..baa9a6f2 100644 --- a/charts/nextcloud/values.yaml +++ b/charts/nextcloud/values.yaml @@ -408,8 +408,6 @@ externalDatabase: hostKey: # -- e.g. db-name databaseKey: - # -- complete URL with type, username and password (current only for notify_push used) - databaseURLKey: db-url ## ## MariaDB chart configuration @@ -421,6 +419,9 @@ mariadb: # To use an ALREADY DEPLOYED mariadb database, set this to false and configure the externalDatabase parameters enabled: false + image: + registry: "docker.io" + # see: https://github.com/bitnami/charts/tree/main/bitnami/mariadb#global-parameters global: # overwrites the primary.persistence.storageClass value @@ -454,6 +455,8 @@ mariadb: ## postgresql: enabled: false + image: + registry: "docker.io" global: postgresql: # global.postgresql.auth overrides postgresql.auth @@ -705,6 +708,8 @@ notifyPush: pullPolicy: IfNotPresent pullSecrets: # - myRegistrKeySecretName + # -- option to set the redis_url per env (if a external redis is used) e.g.: `value: ""` or `valueFrom: {secretKeyRef:{name:"",key:""}}` + redisURLEnv: resources: {}