diff --git a/charts/invenio/templates/_helpers.tpl b/charts/invenio/templates/_helpers.tpl index 1dae654..b1967bb 100644 --- a/charts/invenio/templates/_helpers.tpl +++ b/charts/invenio/templates/_helpers.tpl @@ -299,3 +299,36 @@ Add sentry environmental variables key: {{ .Values.invenio.sentry.secretKeys.dsnKey }} {{- end }} {{- end -}} + +{{/* +Invenio basic configuration variables +*/}} +{{- define "invenio.configBase" -}} +INVENIO_ACCOUNTS_SESSION_REDIS_URL: 'redis://{{ include "invenio.redis.hostname" . }}:6379/1' +INVENIO_APP_ALLOWED_HOSTS: '["{{ include "invenio.hostname" $ }}"]' +INVENIO_CACHE_REDIS_HOST: '{{ include "invenio.redis.hostname" . }}' +INVENIO_CACHE_REDIS_URL: 'redis://{{ include "invenio.redis.hostname" . }}:6379/0' +INVENIO_CELERY_RESULT_BACKEND: 'redis://{{ include "invenio.redis.hostname" . }}:6379/2' +INVENIO_IIIF_CACHE_REDIS_URL: 'redis://{{ include "invenio.redis.hostname" . }}:6379/0' +INVENIO_RATELIMIT_STORAGE_URI: 'redis://{{ include "invenio.redis.hostname" . }}:6379/3' +INVENIO_COMMUNITIES_IDENTITIES_CACHE_REDIS_URL: 'redis://{{ include "invenio.redis.hostname" . }}:6379/4' +INVENIO_SEARCH_HOSTS: {{ printf "[{'host': '%s'}]" (include "invenio.opensearch.hostname" .) | quote }} +INVENIO_SITE_HOSTNAME: '{{ include "invenio.hostname" $ }}' +INVENIO_SITE_UI_URL: 'https://{{ include "invenio.hostname" $ }}' +INVENIO_SITE_API_URL: 'https://{{ include "invenio.hostname" $ }}/api' +INVENIO_DATACITE_ENABLED: "False" +INVENIO_LOGGING_CONSOLE_LEVEL: "WARNING" +{{- end -}} + +{{/* +Merge invenio.extraConfig and configBase using mergeOverwrite and rendering templates. +invenio.ExtraConfig will overwrite the values from configBase in case of duplicates. +*/}} +{{- define "invenio.mergeConfig" -}} +{{- $dst := dict -}} +{{- $values := list (include "invenio.configBase" .) (.Values.invenio.extraConfig | toYaml) -}} +{{- range $values -}} +{{- $dst = tpl . $ | fromYaml | mergeOverwrite $dst -}} +{{- end -}} +{{- $dst | toYaml -}} +{{- end -}} diff --git a/charts/invenio/templates/invenio-configmap.yaml b/charts/invenio/templates/invenio-configmap.yaml index a6a1a0c..52c48e2 100644 --- a/charts/invenio/templates/invenio-configmap.yaml +++ b/charts/invenio/templates/invenio-configmap.yaml @@ -6,25 +6,4 @@ metadata: labels: {{- include "invenio.labels" . | nindent 4 }} data: - INVENIO_ACCOUNTS_SESSION_REDIS_URL: 'redis://{{ include "invenio.redis.hostname" . }}:6379/1' - INVENIO_APP_ALLOWED_HOSTS: '["{{ include "invenio.hostname" $ }}"]' - INVENIO_CACHE_REDIS_HOST: '{{ include "invenio.redis.hostname" . }}' - INVENIO_CACHE_REDIS_URL: 'redis://{{ include "invenio.redis.hostname" . }}:6379/0' - INVENIO_CELERY_RESULT_BACKEND: 'redis://{{ include "invenio.redis.hostname" . }}:6379/2' - INVENIO_IIIF_CACHE_REDIS_URL: 'redis://{{ include "invenio.redis.hostname" . }}:6379/0' - INVENIO_RATELIMIT_STORAGE_URI: 'redis://{{ include "invenio.redis.hostname" . }}:6379/3' - INVENIO_COMMUNITIES_IDENTITIES_CACHE_REDIS_URL: 'redis://{{ include "invenio.redis.hostname" . }}:6379/4' - {{- if not (hasKey .Values.invenio.extra_config "INVENIO_SEARCH_HOSTS") }} - INVENIO_SEARCH_HOSTS: {{ printf "[{'host': '%s'}]" (include "invenio.opensearch.hostname" .) | quote }} - {{- end }} - INVENIO_SITE_HOSTNAME: '{{ include "invenio.hostname" $ }}' - INVENIO_SITE_UI_URL: 'https://{{ include "invenio.hostname" $ }}' - INVENIO_SITE_API_URL: 'https://{{ include "invenio.hostname" $ }}/api' - INVENIO_DATACITE_ENABLED: "False" - INVENIO_LOGGING_CONSOLE_LEVEL: "WARNING" - {{- range $key, $value := .Values.invenio.extra_config }} - {{ $key }}: {{ $value | toYaml | indent 4 | trim }} - {{- end }} - {{- range $key, $value := .Values.invenio.extraConfig }} - {{ $key }}: {{ tpl $value $ | toYaml | indent 4 | trim }} - {{- end }} + {{- include "invenio.mergeConfig" . | nindent 2 -}} diff --git a/charts/invenio/templates/web-deployment.yaml b/charts/invenio/templates/web-deployment.yaml index ea12705..7ecdcca 100644 --- a/charts/invenio/templates/web-deployment.yaml +++ b/charts/invenio/templates/web-deployment.yaml @@ -5,6 +5,8 @@ metadata: name: web labels: {{- include "invenio.labels" . | nindent 4 }} + annotations: + checksum/invenio-configmap: {{ include (print $.Template.BasePath "/invenio-configmap.yaml") . | sha256sum }} spec: replicas: {{ .Values.web.replicas }} selector: diff --git a/charts/invenio/templates/worker-beat-deployment.yaml b/charts/invenio/templates/worker-beat-deployment.yaml index f360995..01a8913 100644 --- a/charts/invenio/templates/worker-beat-deployment.yaml +++ b/charts/invenio/templates/worker-beat-deployment.yaml @@ -5,6 +5,8 @@ metadata: name: worker-beat labels: {{- include "invenio.labels" . | nindent 4 }} + annotations: + checksum/invenio-configmap: {{ include (print $.Template.BasePath "/invenio-configmap.yaml") . | sha256sum }} spec: replicas: 1 selector: diff --git a/charts/invenio/templates/worker-deployment.yaml b/charts/invenio/templates/worker-deployment.yaml index d505f7f..1dcf4ca 100644 --- a/charts/invenio/templates/worker-deployment.yaml +++ b/charts/invenio/templates/worker-deployment.yaml @@ -5,6 +5,8 @@ metadata: name: worker labels: {{- include "invenio.labels" . | nindent 4 }} + annotations: + checksum/invenio-configmap: {{ include (print $.Template.BasePath "/invenio-configmap.yaml") . | sha256sum }} spec: replicas: {{ .Values.worker.replicas }} selector: