diff --git a/helm/alfresco-content-services/templates/_helpers.tpl b/helm/alfresco-content-services/templates/_helpers.tpl index a834dbe6a0..272ae223bd 100644 --- a/helm/alfresco-content-services/templates/_helpers.tpl +++ b/helm/alfresco-content-services/templates/_helpers.tpl @@ -5,4 +5,49 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this {{- define "content-services.fullname" -}} {{- $name := default .Chart.Name .Values.nameOverride -}} {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} -{{- end -}} \ No newline at end of file +{{- end -}} + +{{/* +Get the Database hostname depending on the Database type +*/}} +{{- define "database.hostname" -}} +{{- if eq ( .Values.database.type | toString ) "postgresql" }} +{{- printf "%s-%s" .Release.Name .Values.postgresql.nameOverride -}} +{{- end }} +{{- end -}} + +{{/* +Get the Database port depending on the Database type +*/}} +{{- define "database.port" -}} +{{- if eq ( .Values.database.type | toString ) "postgresql" }} +{{- print .Values.postgresql.service.port -}} +{{- end }} +{{- end -}} + +{{/* +Create the Database driver depending on the Database type +*/}} +{{- define "database.driver" -}} +{{- if eq ( .Values.database.type | toString ) "postgresql" }} +{{- print .Values.postgresql.driver -}} +{{- end }} +{{- end -}} + +{{/* +Get the Database user depending on the Database type +*/}} +{{- define "database.user" -}} +{{- if eq ( .Values.database.type | toString ) "postgresql" }} +{{- print .Values.postgresql.postgresUser -}} +{{- end }} +{{- end -}} + +{{/* +Get the Database password depending on the Database type +*/}} +{{- define "database.password" }} +{{- if eq ( .Values.database.type | toString ) "postgresql" -}} +{{- print .Values.postgresql.postgresPassword -}} +{{- end }} +{{- end -}} diff --git a/helm/alfresco-content-services/templates/config-repository.yaml b/helm/alfresco-content-services/templates/config-repository.yaml index 77a5ca87b1..5f16955e51 100644 --- a/helm/alfresco-content-services/templates/config-repository.yaml +++ b/helm/alfresco-content-services/templates/config-repository.yaml @@ -17,9 +17,9 @@ data: -Dalfresco.port={{ .Values.repository.service.externalPort }} -Dshare.host={{ template "content-services.fullname" . }}-share -Dshare.port={{ .Values.share.service.externalPort }} - -Ddb.driver=org.postgresql.Driver - -Ddb.username={{ .Values.postgresql.postgresUser }} - -Ddb.password={{ .Values.postgresql.postgresPassword }} - -Ddb.url=jdbc:postgresql://{{ .Release.Name }}-postgresql-acs:5432/{{ .Values.postgresql.postgresDatabase }} + -Ddb.driver={{ template "database.driver" . }} + -Ddb.username={{ template "database.user" . }} + -Ddb.password={{ template "database.password" . }} + -Ddb.url=jdbc:{{ .Values.database.type }}://{{ template "database.hostname" . }}:{{ template "database.port" . }}/{{ .Values.postgresql.postgresDatabase }} -Dsolr.host={{ template "content-services.fullname" . }}-solr - -Dsolr.port={{ .Values.solr.service.externalPort }}" \ No newline at end of file + -Dsolr.port={{ .Values.solr.service.externalPort }}" diff --git a/helm/alfresco-content-services/templates/deployment-repository.yaml b/helm/alfresco-content-services/templates/deployment-repository.yaml index 2fd87a2a1a..84ecceb699 100644 --- a/helm/alfresco-content-services/templates/deployment-repository.yaml +++ b/helm/alfresco-content-services/templates/deployment-repository.yaml @@ -29,6 +29,6 @@ spec: resources: {{ toYaml .Values.repository.resources | indent 12 }} initContainers: - - name: init-postgres + - name: init-db image: busybox - command: ['sh', '-c', 'until nslookup {{ .Release.Name }}-postgresql-acs; do echo "waiting for postgres"; sleep 2; done;'] + command: ['sh', '-c', 'until nc -w1 {{ template "database.hostname" . }} {{ template "database.port" . }}; do echo "waiting for {{ .Values.database.type }}"; sleep 2; done;'] diff --git a/helm/alfresco-content-services/values.yaml b/helm/alfresco-content-services/values.yaml index 8637c91f8e..45a0d66753 100644 --- a/helm/alfresco-content-services/values.yaml +++ b/helm/alfresco-content-services/values.yaml @@ -82,5 +82,9 @@ postgresql: memory: "250Mi" limits: memory: "500Mi" + driver: org.postgresql.Driver + +database: + type: postgresql replicaCount: 1