From 7478b49c9cdb0924c2aee9ba65ffbf3b024ed3e0 Mon Sep 17 00:00:00 2001 From: Emilien Devos Date: Tue, 19 Sep 2023 14:12:18 +0200 Subject: [PATCH] add rabbitmq support into helm chart --- Chart.lock | 9 +- Chart.yaml | 7 +- templates/_helpers-database.tpl | 44 +++++++ templates/_helpers-envs.tpl | 51 +++++++++ templates/_helpers-ldap.tpl | 33 ++++++ templates/_helpers-rabbitmq.tpl | 38 +++++++ templates/_helpers.tpl | 133 +--------------------- templates/console/console-deployment.yaml | 1 + templates/rabbitmq/rabbitmq-secret.yaml | 19 ++++ values.yaml | 9 ++ 10 files changed, 208 insertions(+), 136 deletions(-) create mode 100644 templates/_helpers-database.tpl create mode 100644 templates/_helpers-envs.tpl create mode 100644 templates/_helpers-ldap.tpl create mode 100644 templates/_helpers-rabbitmq.tpl create mode 100644 templates/rabbitmq/rabbitmq-secret.yaml diff --git a/Chart.lock b/Chart.lock index 4db0146..32c7cd6 100644 --- a/Chart.lock +++ b/Chart.lock @@ -1,6 +1,9 @@ dependencies: - name: postgresql repository: https://charts.bitnami.com/bitnami/ - version: 12.1.15 -digest: sha256:fafad9c35344a9fa85f52ea0764a2d5c40e247eef01220edbf6d21dcc7541426 -generated: "2023-02-16T17:52:10.601623147+01:00" + version: 12.11.2 +- name: rabbitmq + repository: https://charts.bitnami.com/bitnami/ + version: 12.1.4 +digest: sha256:d4a4c0c3ea33e653b9d89f03722b52687128d7532d9dc0e408f6ba4960439c1f +generated: "2023-09-19T14:06:17.738408641+02:00" diff --git a/Chart.yaml b/Chart.yaml index f793de3..1382a46 100644 --- a/Chart.yaml +++ b/Chart.yaml @@ -25,7 +25,12 @@ appVersion: "22.0" dependencies: - name: postgresql - version: ~12.1.14 + version: ~12.11.2 repository: "https://charts.bitnami.com/bitnami/" condition: database.builtin alias: database +- name: rabbitmq + version: ~12.1.4 + repository: "https://charts.bitnami.com/bitnami/" + condition: rabbitmq.builtin + alias: rabbitmq \ No newline at end of file diff --git a/templates/_helpers-database.tpl b/templates/_helpers-database.tpl new file mode 100644 index 0000000..5b6627b --- /dev/null +++ b/templates/_helpers-database.tpl @@ -0,0 +1,44 @@ +{{/* +Insert database georchestra environment variables +*/}} +{{- define "georchestra.database-georchestra-envs" -}} +{{- $database := .Values.database -}} +{{- $database_secret_georchestra_name := "" -}} +{{- if $database.builtin }} +{{- $database_secret_georchestra_name = printf "%s-database-georchestra-secret" (include "georchestra.fullname" .) -}} +- name: PGHOST + value: "{{ .Release.Name }}-database" +{{- else }} +{{- $database_secret_georchestra_name = .Values.database.auth.existingSecret -}} +- name: PGHOST + valueFrom: + secretKeyRef: + name: {{ $database_secret_georchestra_name }} + key: host + optional: false +{{- end }} +- name: PGPORT + valueFrom: + secretKeyRef: + name: {{ $database_secret_georchestra_name }} + key: port + optional: false +- name: PGDATABASE + valueFrom: + secretKeyRef: + name: {{ $database_secret_georchestra_name }} + key: dbname + optional: false +- name: PGUSER + valueFrom: + secretKeyRef: + name: {{ $database_secret_georchestra_name }} + key: user + optional: false +- name: PGPASSWORD + valueFrom: + secretKeyRef: + name: {{ $database_secret_georchestra_name }} + key: password + optional: false +{{- end }} \ No newline at end of file diff --git a/templates/_helpers-envs.tpl b/templates/_helpers-envs.tpl new file mode 100644 index 0000000..1c90c41 --- /dev/null +++ b/templates/_helpers-envs.tpl @@ -0,0 +1,51 @@ +{{/* +Insert service host environment variables +*/}} +{{- define "georchestra.service-envs" -}} +- name: ANALYTICS_HOST + value: "{{ include "georchestra.fullname" . }}-analytics-svc" +- name: CAS_HOST + value: "{{ include "georchestra.fullname" . }}-cas-svc" +- name: CONSOLE_HOST + value: "{{ include "georchestra.fullname" . }}-console-svc" +- name: GEONETWORK_HOST + value: "{{ include "georchestra.fullname" . }}-geonetwork-svc" +- name: GEOSERVER_HOST + value: "{{ include "georchestra.fullname" . }}-geoserver-svc" +- name: HEADER_HOST + value: "{{ include "georchestra.fullname" . }}-header-svc" +- name: GEOWEBCACHE_HOST + value: "{{ include "georchestra.fullname" . }}-geowebcache-svc" +- name: MAPSTORE_HOST + value: "{{ include "georchestra.fullname" . }}-mapstore-svc" +- name: DATAFEEDER_HOST + value: "{{ include "georchestra.fullname" . }}-datafeeder-svc" +- name: IMPORT_HOST + value: "{{ include "georchestra.fullname" . }}-import-svc" +- name: DATAHUB_HOST + value: "datahub-datahub-svc" +- name: OGC_API_RECORDS_HOST + value: "{{ include "georchestra.fullname" . }}-gn4-ogc-api-records-svc" +- name: ES_HOST + value: "{{ include "georchestra.fullname" . }}-gn4-elasticsearch-svc" +- name: ES_PORT + value: "9200" +- name: KB_HOST + value: "{{ include "georchestra.fullname" . }}-gn4-kibana-svc" +- name: KB_PORT + value: "5601" +{{- end }} + +{{/* +Insert common environment variables +*/}} +{{- define "georchestra.common-envs" -}} +- name: FQDN + value: "{{ .Values.fqdn }}" +{{- if .Values.georchestra.smtp_smarthost.enabled }} +- name: SMTPHOST + value: "{{ include "georchestra.fullname" . }}-smtp-svc" +- name: SMTPPORT + value: "25" +{{- end }} +{{- end }} \ No newline at end of file diff --git a/templates/_helpers-ldap.tpl b/templates/_helpers-ldap.tpl new file mode 100644 index 0000000..4b4ef12 --- /dev/null +++ b/templates/_helpers-ldap.tpl @@ -0,0 +1,33 @@ +{{/* +Insert LDAP environment variables +*/}} +{{- define "georchestra.ldap-envs" -}} +{{- $ldap := .Values.ldap -}} +{{- if .Values.georchestra.webapps.openldap.enabled }} +- name: LDAPHOST + value: "{{ include "georchestra.fullname" . }}-ldap-svc" +{{- else }} +- name: LDAPHOST + value: "{{ $ldap.host }}" +{{- end }} +- name: LDAPPORT + value: "{{ $ldap.port }}" +- name: LDAPSCHEME + value: "{{ $ldap.scheme }}" +- name: LDAPBASEDN + value: "{{ $ldap.baseDn }}" +- name: LDAPADMINDN + value: "{{ $ldap.adminDn }}" +- name: LDAPADMINPASSWORD + valueFrom: + secretKeyRef: + name: {{ $ldap.existingSecret | default (printf "%s-ldap-passwords-secret" (include "georchestra.fullname" .)) }} + key: SLAPD_PASSWORD + optional: false +- name: LDAPUSERSRDN + value: "{{ $ldap.usersRdn }}" +- name: LDAPROLESRDN + value: "{{ $ldap.rolesRdn }}" +- name: LDAPORGSRDN + value: "{{ $ldap.orgsRdn }}" +{{- end }} \ No newline at end of file diff --git a/templates/_helpers-rabbitmq.tpl b/templates/_helpers-rabbitmq.tpl new file mode 100644 index 0000000..fd64dde --- /dev/null +++ b/templates/_helpers-rabbitmq.tpl @@ -0,0 +1,38 @@ +{{/* +Insert rabbitmq georchestra environment variables +*/}} +{{- define "georchestra.rabbitmq-georchestra-envs" -}} +{{- $rabbitmq := .Values.rabbitmq -}} +{{- $rabbitmq_secret_georchestra_name := "" -}} +{{- if $rabbitmq.builtin }} +{{- $rabbitmq_secret_georchestra_name = printf "%s-rabbitmq-georchestra-secret" (include "georchestra.fullname" .) -}} +- name: RABBITMQ_HOST + value: "{{ .Release.Name }}-rabbitmq" +{{- else }} +{{- $rabbitmq_secret_georchestra_name = .Values.rabbitmq.auth.existingSecret -}} +- name: RABBITMQ_HOST + valueFrom: + secretKeyRef: + name: {{ $rabbitmq_secret_georchestra_name }} + key: host + optional: false +{{- end }} +- name: RABBITMQ_PORT + valueFrom: + secretKeyRef: + name: {{ $rabbitmq_secret_georchestra_name }} + key: port + optional: false +- name: RABBITMQ_USERNAME + valueFrom: + secretKeyRef: + name: {{ $rabbitmq_secret_georchestra_name }} + key: user + optional: false +- name: RABBITMQ_PASSWORD + valueFrom: + secretKeyRef: + name: {{ $rabbitmq_secret_georchestra_name }} + key: password + optional: false +{{- end }} \ No newline at end of file diff --git a/templates/_helpers.tpl b/templates/_helpers.tpl index 799f88c..c8eb608 100644 --- a/templates/_helpers.tpl +++ b/templates/_helpers.tpl @@ -59,135 +59,4 @@ Create the name of the service account to use {{- else }} {{- default "default" .Values.serviceAccount.name }} {{- end }} -{{- end }} - -{{/* -Insert database georchestra environment variables -*/}} -{{- define "georchestra.database-georchestra-envs" -}} -{{- $database := .Values.database -}} -{{- $database_secret_georchestra_name := "" -}} -{{- if $database.builtin }} -{{- $database_secret_georchestra_name = printf "%s-database-georchestra-secret" (include "georchestra.fullname" .) -}} -- name: PGHOST - value: "{{ .Release.Name }}-database" -{{- else }} -{{- $database_secret_georchestra_name = .Values.database.auth.existingSecret -}} -- name: PGHOST - valueFrom: - secretKeyRef: - name: {{ $database_secret_georchestra_name }} - key: host - optional: false -{{- end }} -- name: PGPORT - valueFrom: - secretKeyRef: - name: {{ $database_secret_georchestra_name }} - key: port - optional: false -- name: PGDATABASE - valueFrom: - secretKeyRef: - name: {{ $database_secret_georchestra_name }} - key: dbname - optional: false -- name: PGUSER - valueFrom: - secretKeyRef: - name: {{ $database_secret_georchestra_name }} - key: user - optional: false -- name: PGPASSWORD - valueFrom: - secretKeyRef: - name: {{ $database_secret_georchestra_name }} - key: password - optional: false -{{- end }} - -{{/* -Insert LDAP environment variables -*/}} -{{- define "georchestra.ldap-envs" -}} -{{- $ldap := .Values.ldap -}} -{{- if .Values.georchestra.webapps.openldap.enabled }} -- name: LDAPHOST - value: "{{ include "georchestra.fullname" . }}-ldap-svc" -{{- else }} -- name: LDAPHOST - value: "{{ $ldap.host }}" -{{- end }} -- name: LDAPPORT - value: "{{ $ldap.port }}" -- name: LDAPSCHEME - value: "{{ $ldap.scheme }}" -- name: LDAPBASEDN - value: "{{ $ldap.baseDn }}" -- name: LDAPADMINDN - value: "{{ $ldap.adminDn }}" -- name: LDAPADMINPASSWORD - valueFrom: - secretKeyRef: - name: {{ $ldap.existingSecret | default (printf "%s-ldap-passwords-secret" (include "georchestra.fullname" .)) }} - key: SLAPD_PASSWORD - optional: false -- name: LDAPUSERSRDN - value: "{{ $ldap.usersRdn }}" -- name: LDAPROLESRDN - value: "{{ $ldap.rolesRdn }}" -- name: LDAPORGSRDN - value: "{{ $ldap.orgsRdn }}" -{{- end }} - -{{/* -Insert service host environment variables -*/}} -{{- define "georchestra.service-envs" -}} -- name: ANALYTICS_HOST - value: "{{ include "georchestra.fullname" . }}-analytics-svc" -- name: CAS_HOST - value: "{{ include "georchestra.fullname" . }}-cas-svc" -- name: CONSOLE_HOST - value: "{{ include "georchestra.fullname" . }}-console-svc" -- name: GEONETWORK_HOST - value: "{{ include "georchestra.fullname" . }}-geonetwork-svc" -- name: GEOSERVER_HOST - value: "{{ include "georchestra.fullname" . }}-geoserver-svc" -- name: HEADER_HOST - value: "{{ include "georchestra.fullname" . }}-header-svc" -- name: GEOWEBCACHE_HOST - value: "{{ include "georchestra.fullname" . }}-geowebcache-svc" -- name: MAPSTORE_HOST - value: "{{ include "georchestra.fullname" . }}-mapstore-svc" -- name: DATAFEEDER_HOST - value: "{{ include "georchestra.fullname" . }}-datafeeder-svc" -- name: IMPORT_HOST - value: "{{ include "georchestra.fullname" . }}-import-svc" -- name: DATAHUB_HOST - value: "datahub-datahub-svc" -- name: OGC_API_RECORDS_HOST - value: "{{ include "georchestra.fullname" . }}-gn4-ogc-api-records-svc" -- name: ES_HOST - value: "{{ include "georchestra.fullname" . }}-gn4-elasticsearch-svc" -- name: ES_PORT - value: "9200" -- name: KB_HOST - value: "{{ include "georchestra.fullname" . }}-gn4-kibana-svc" -- name: KB_PORT - value: "5601" -{{- end }} - -{{/* -Insert common environment variables -*/}} -{{- define "georchestra.common-envs" -}} -- name: FQDN - value: "{{ .Values.fqdn }}" -{{- if .Values.georchestra.smtp_smarthost.enabled }} -- name: SMTPHOST - value: "{{ include "georchestra.fullname" . }}-smtp-svc" -- name: SMTPPORT - value: "25" -{{- end }} -{{- end }} +{{- end }} \ No newline at end of file diff --git a/templates/console/console-deployment.yaml b/templates/console/console-deployment.yaml index e28699b..6bb33a9 100644 --- a/templates/console/console-deployment.yaml +++ b/templates/console/console-deployment.yaml @@ -35,6 +35,7 @@ spec: {{- include "georchestra.common-envs" . | nindent 10 }} {{- include "georchestra.ldap-envs" . | nindent 10 }} {{- include "georchestra.database-georchestra-envs" . | nindent 10 }} + {{- include "georchestra.rabbitmq-georchestra-envs" . | nindent 10 }} {{- if $webapp.extra_environment }} {{- $webapp.extra_environment | toYaml | nindent 10 }} {{- end }} diff --git a/templates/rabbitmq/rabbitmq-secret.yaml b/templates/rabbitmq/rabbitmq-secret.yaml new file mode 100644 index 0000000..f40b8f2 --- /dev/null +++ b/templates/rabbitmq/rabbitmq-secret.yaml @@ -0,0 +1,19 @@ +{{- $rabbitmq := .Values.rabbitmq -}} +{{- if not $rabbitmq.auth.existingSecret -}} +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "georchestra.fullname" . }}-rabbitmq-georchestra-secret + labels: + {{- include "georchestra.labels" . | nindent 4 }} +type: Opaque +data: + {{- if $rabbitmq.builtin }} + host: {{ printf "%s-rabbitmq" .Release.Name | b64enc | quote }} + {{- else }} + host: {{ $rabbitmq.auth.host | b64enc | quote }} + {{- end }} + password: {{ $rabbitmq.auth.password | b64enc | quote }} + port: {{ $rabbitmq.auth.port | b64enc | quote }} + user: {{ $rabbitmq.auth.username | b64enc | quote }} +{{- end }} diff --git a/values.yaml b/values.yaml index c5213f8..f586757 100644 --- a/values.yaml +++ b/values.yaml @@ -252,3 +252,12 @@ database: ssl: false password: datafeeder username: datafeeder + +rabbitmq: + builtin: true + auth: + username: georchestra + password: georchestra +# host: rabbitmq + port: "5672" +# existingSecret: mysecret \ No newline at end of file