diff --git a/swh/templates/listers/configmap.yaml b/swh/templates/listers/configmap.yaml index d90e47d..3935773 100644 --- a/swh/templates/listers/configmap.yaml +++ b/swh/templates/listers/configmap.yaml @@ -1,51 +1,27 @@ {{ if .Values.listers.enabled -}} {{- range $lister_type, $deployment_config := .Values.listers.deployments -}} {{- $lister_name := ( print "lister-" $lister_type ) -}} --- apiVersion: v1 kind: ConfigMap metadata: - name: {{ $lister_name }} + name: {{ $lister_name }}-template namespace: {{ $.Values.namespace }} data: - config.yml: | + config.yml.template: | storage: cls: remote url: http://{{ $.Values.listers.storage.host }}:{{ $.Values.listers.storage.port }}/ scheduler: cls: remote url: http://{{ $.Values.listers.scheduler.host }}:{{ $.Values.listers.scheduler.port }}/ - celery: - task_broker: ##amqp_host## + task_broker: ${host} task_queues: {{- range $queue := get $deployment_config "queues" }} - {{ $queue }} {{- end }} - entrypoint.sh: | - #!/bin/bash - - set -e - - # Create the full config filename - cat /etc/softwareheritage/config.yml > $SWH_CONFIG_FILENAME - # contains required credentials for lister - cat /etc/credentials/listers/data >> $SWH_CONFIG_FILENAME - - # Install the rabbitmq host information - sed -i 's,##amqp_host##,'$RABBITMQ_HOST',g' $SWH_CONFIG_FILENAME - - echo Starting the swh Celery worker - exec python -m celery \ - --app=swh.scheduler.celery_backend.config.app \ - worker \ - --pool=prefork \ - --concurrency=${CONCURRENCY} \ - --max-tasks-per-child=${MAX_TASKS_PER_CHILD} \ - -Ofair --loglevel=${LOGLEVEL} \ - --without-gossip \ - --without-mingle \ - --without-heartbeat \ - --hostname "${HOSTNAME}" + # credentials + ${data} {{ end }} {{- end -}} diff --git a/swh/templates/listers/deployment.yaml b/swh/templates/listers/deployment.yaml index 943803b..dbd5e65 100644 --- a/swh/templates/listers/deployment.yaml +++ b/swh/templates/listers/deployment.yaml @@ -1,107 +1,117 @@ {{ if .Values.listers.enabled -}} {{- $configurationChecksum := include (print $.Template.BasePath "/listers/configmap.yaml") . -}} {{- range $lister_type, $deployment_config := .Values.listers.deployments -}} {{- $lister_name := ( print "lister-" $lister_type ) -}} --- apiVersion: apps/v1 kind: Deployment metadata: name: {{ $lister_name }} namespace: {{ $.Values.namespace }} labels: app: {{ $lister_name }} spec: selector: matchLabels: app: {{ $lister_name }} strategy: type: RollingUpdate rollingUpdate: maxSurge: 1 template: metadata: labels: app: {{ $lister_name }} annotations: # Force a rollout upgrade if the configuration changes checksum/config: {{ $configurationChecksum | sha256sum }} spec: {{- if $.Values.listers.affinity }} affinity: {{ toYaml $.Values.listers.affinity | nindent 8 }} {{- end }} + initContainers: + - name: prepare-configuration + image: debian:bullseye + imagePullPolicy: Always + envFrom: + - secretRef: + name: lister-credentials-secrets + - secretRef: + name: amqp-access-credentials + command: + - /bin/bash + args: + - -c + - eval echo "\"$( /etc/swh/config.yml + volumeMounts: + - name: configuration + mountPath: /etc/swh + - name: configuration-template + mountPath: /etc/swh/configuration-template containers: - name: listers - image: {{ $.Values.swh_listers_image }}:{{ $.Values.swh_listers_image_version }} - imagePullPolicy: Always - command: - - /entrypoint.sh resources: requests: memory: {{ get $deployment_config "requestedMemory" | default "512Mi" }} cpu: {{ get $deployment_config "requestedCpu" | default "500m" }} limits: memory: "4000Mi" cpu: "1200m" + image: {{ $.Values.swh_listers_image }}:{{ $.Values.swh_listers_image_version }} + imagePullPolicy: Always + command: + - /bin/bash + args: + - -c + - /opt/swh/entrypoint.sh lifecycle: preStop: exec: command: ["kill", "1"] env: - name: STATSD_HOST value: {{ $.Values.statsdExternalHost | default "prometheus-statsd-exporter" }} - name: STATSD_PORT value: {{ $.Values.statsdPort | default "9125" | quote }} - name: CONCURRENCY value: "1" - name: MAX_TASKS_PER_CHILD value: "1" - name: LOGLEVEL value: "INFO" - name: SWH_CONFIG_FILENAME # FIXME: built by entrypoint.sh, determine how to properly declare this value: /tmp/config.yml - name: SWH_SENTRY_ENVIRONMENT value: {{ $.Values.sentry.environment }} - name: SWH_MAIN_PACKAGE value: {{ $.Values.listers.sentrySwhPackage }} - name: SWH_SENTRY_DSN valueFrom: secretKeyRef: name: lister-sentry-secrets key: sentry-dsn # 'name' secret must exist & include key "host" optional: false - name: RABBITMQ_HOST valueFrom: secretKeyRef: name: amqp-access-credentials key: host # 'name' secret must exist & include key "host" optional: false volumeMounts: - - name: config - mountPath: /etc/softwareheritage/config.yml - subPath: config.yml - readOnly: true - - name: config - mountPath: /entrypoint.sh - subPath: entrypoint.sh - readOnly: true - - name: lister-credentials-secrets - mountPath: /etc/credentials/listers - readOnly: true - - mountPath: /tmp - name: tmp-volume + - name: configuration + mountPath: /etc/swh/config.yml volumes: - - name: config - configMap: - name: {{ $lister_name }} - defaultMode: 0777 - - name: tmp-volume - emptyDir: {} - - name: lister-credentials-secrets - secret: - secretName: lister-credentials-secrets + - name: configuration + emptyDir: {} + - name: configuration-template + configMap: + name: {{ $lister_name }}-template + items: + - key: "config.yml.template" + path: "config.yml.template" {{ end }} {{- end -}}