diff --git a/swh/templates/web/_helper-cronjob.yaml b/swh/templates/web/_helper-cronjob.yaml index 258672673eca75832f5119acacb9054918f2d10c..34be68444499c9112c79772104d9674dd626104a 100644 --- a/swh/templates/web/_helper-cronjob.yaml +++ b/swh/templates/web/_helper-cronjob.yaml @@ -4,6 +4,7 @@ {{- define "swh.web.cronjob" -}} {{- with .configuration -}} {{- $log_level := .logLevel -}} +--- apiVersion: batch/v1 kind: CronJob metadata: @@ -28,13 +29,16 @@ spec: initContainers: {{- if $.pgService }} - name: prepare-pgservice-configuration - image: debian:bullseye + image: {{ $.Values.swh_utils_image }}:{{ $.Values.swh_utils_image_version }} imagePullPolicy: IfNotPresent command: - /bin/bash args: - -c - - eval "cp /etc/swh/config/pg_service.conf /etc/swh/.pg_service.conf" + - eval "cat /etc/swh/config/pg_service.conf | envsubst > /etc/swh/.pg_service.conf" + env: + {{- include "swh.secrets.envFromDeploymentConfig" (dict "deploymentConfig" $.webConfiguration + "Values" $.Values) | nindent 16 }} volumeMounts: - name: configuration mountPath: /etc/swh @@ -86,6 +90,7 @@ spec: command: - /opt/swh/entrypoint.sh args: + - django-admin {{- range $cmd := $.command }} - {{ $cmd }} {{- end }} @@ -140,7 +145,7 @@ spec: {{- if $.pgService }} - name: pgservice-configuration-template configMap: - name: pgservice-{{ $.webType }}-configuration-template + name: {{ lower $.serviceType }}-config-template items: - key: "pg-service-conf" path: "pg_service.conf" diff --git a/swh/templates/web/configmap-pgservice.yaml b/swh/templates/web/configmap-pgservice.yaml deleted file mode 100644 index d65e614f2e5813aa90d07971c154f798f96af65d..0000000000000000000000000000000000000000 --- a/swh/templates/web/configmap-pgservice.yaml +++ /dev/null @@ -1,20 +0,0 @@ -{{- if .Values.web.enabled -}} -{{ range $web_type, $web_config := .Values.web.deployments }} -{{- if and (or (not (hasKey $web_config "enabled")) - (get $web_config "enabled")) - (hasKey $web_config "syncMailmaps") - $web_config.syncMailmaps.enabled -}} ---- -apiVersion: v1 -kind: ConfigMap -metadata: - name: pgservice-{{ $web_type }}-configuration-template - namespace: {{ $.Values.namespace }} -data: - pg-service-conf: | - {{- include "swh.web.pgService" (dict "serviceType" "syncmailmaps" - "configurationRef" $web_config.syncMailmaps.configurationRef - "Values" $.Values) | nindent 4 }} -{{- end -}} -{{ end -}} -{{- end -}} diff --git a/swh/templates/web/cronjob-configmap.yaml b/swh/templates/web/cronjob-configmap.yaml new file mode 100644 index 0000000000000000000000000000000000000000..1b832ae416c11b2fb8d4ec1349a54b4db47675ca --- /dev/null +++ b/swh/templates/web/cronjob-configmap.yaml @@ -0,0 +1,22 @@ +{{ if .Values.web.enabled -}} +{{- range $webType, $webConfig := .Values.web.deployments -}} +{{- if and (or (not (hasKey $webConfig "enabled")) + (get $webConfig "enabled")) -}} +{{- range $cronJobType, $cronJobConfig := $webConfig.cronJobs -}} +{{- if $cronJobConfig.enabled }} +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: web-{{ $webType }}-{{ $cronJobType | lower }}-config-template + namespace: {{ $.Values.namespace }} +data: + pg-service-conf: | + {{- include "swh.web.pgService" (dict "serviceType" (lower $cronJobType) + "configurationRef" $cronJobConfig.configurationRef + "Values" $.Values) | nindent 4 }} +{{- end -}} +{{- end -}} +{{- end -}} +{{- end -}} +{{- end }} diff --git a/swh/templates/web/cronjob.yaml b/swh/templates/web/cronjob.yaml new file mode 100644 index 0000000000000000000000000000000000000000..95d15ebebbbae178c64959dc7ace45ffe9f098ea --- /dev/null +++ b/swh/templates/web/cronjob.yaml @@ -0,0 +1,18 @@ +{{ if .Values.web.enabled -}} +{{ range $webType, $webConfig := .Values.web.deployments }} +{{- if and (or (not (hasKey $webConfig "enabled")) + (get $webConfig "enabled")) -}} +{{- range $cronJobType, $cronJobConfig := $webConfig.cronJobs -}} +{{- if $cronJobConfig.enabled -}} +{{- include "swh.web.cronjob" (dict "Values" $.Values + "serviceType" (print "web-" $webType "-" (lower $cronJobType) ) + "configuration" $cronJobConfig + "webConfiguration" $webConfig + "pgService" true + "webType" $webType + "command" $cronJobConfig.command) -}} +{{- end -}} +{{- end -}} +{{- end -}} +{{ end -}} +{{- end -}} diff --git a/swh/templates/web/sync-mailmaps-cronjob.yaml b/swh/templates/web/sync-mailmaps-cronjob.yaml deleted file mode 100644 index d0122b81cc10bb5919384bc5eaf48bec5c90a7a8..0000000000000000000000000000000000000000 --- a/swh/templates/web/sync-mailmaps-cronjob.yaml +++ /dev/null @@ -1,16 +0,0 @@ -{{ if .Values.web.enabled -}} -{{ range $web_type, $web_config := .Values.web.deployments }} -{{- if and (or (not (hasKey $web_config "enabled")) - (get $web_config "enabled")) - (hasKey $web_config "syncMailmaps") - $web_config.syncMailmaps.enabled -}} -{{- include "swh.web.cronjob" (dict "Values" $.Values - "serviceType" (print "web-" $web_type "-sync-mailmaps") - "configuration" $web_config.syncMailmaps - "webConfiguration" $web_config - "pgService" true - "webType" $web_type - "command" (list "sync-mailmaps" "service=syncmailmaps")) -}} -{{- end -}} -{{ end -}} -{{- end -}} diff --git a/swh/values/production/swh.yaml b/swh/values/production/swh.yaml index a345d4984ab554c74226e85664133412d8936fab..500c5d8e0734194a179a92484c6f83ac4c33a9ac 100644 --- a/swh/values/production/swh.yaml +++ b/swh/values/production/swh.yaml @@ -1429,12 +1429,16 @@ web: concurrencyPolicy: Forbid priorityClassName: frontend-rpc-workload cron: "*/2 * * * *" - syncMailmaps: - enabled: true - concurrencyPolicy: Forbid - configurationRef: postgresqlSyncmailmapsConfiguration - priorityClassName: frontend-rpc-workload - cron: "15 * * * *" + cronJobs: + syncMailmaps: + enabled: true + command: + - "sync_mailmaps" + - "service=syncmailmaps" + concurrencyPolicy: Forbid + configurationRef: postgresqlSyncmailmapsConfiguration + priorityClassName: frontend-rpc-workload + cron: "15 * * * *" hosts: - archive.softwareheritage.org - base.softwareheritage.org diff --git a/swh/values/staging/overrides/swh-cassandra-next-version.yaml b/swh/values/staging/overrides/swh-cassandra-next-version.yaml index f79b6a5e3ae10c6ab471925226e1d41a52ea5e10..30aa1e4f46721ccd76f131b7555c9ba8c01d0b00 100644 --- a/swh/values/staging/overrides/swh-cassandra-next-version.yaml +++ b/swh/values/staging/overrides/swh-cassandra-next-version.yaml @@ -647,8 +647,9 @@ web: - webapp-cassandra-next-version.internal.staging.swh.network refreshSavecodenowStatus: enabled: false - syncMailmaps: - enabled: false + cronJobs: + syncMailmaps: + enabled: false ingress: whitelistSourceRangeRef: stagingNetworkRanges endpoints: diff --git a/swh/values/staging/swh-cassandra.yaml b/swh/values/staging/swh-cassandra.yaml index f7425b2c347392f7bec0f68af26321ff7f4f54ba..c8d7da20a123f0f6209b19409ec99b43d975f152 100644 --- a/swh/values/staging/swh-cassandra.yaml +++ b/swh/values/staging/swh-cassandra.yaml @@ -714,12 +714,16 @@ web: hosts: - webapp.staging.swh.network - webapp-cassandra.internal.staging.swh.network - syncMailmaps: - enabled: true - concurrencyPolicy: Forbid - configurationRef: postgresqlSyncmailmapsConfiguration - priorityClassName: frontend-rpc-workload - cron: "15 * * * *" + cronJobs: + syncMailmaps: + enabled: true + command: + - "sync_mailmaps" + - "service=syncmailmaps" + concurrencyPolicy: Forbid + configurationRef: postgresqlSyncmailmapsConfiguration + priorityClassName: frontend-rpc-workload + cron: "15 * * * *" ingress: enabled: true secretName: swh-web-crt