From 1628335799affad7a3e043d78af789c13a06d355 Mon Sep 17 00:00:00 2001 From: "Jonas Brand (8R0WNI3)" Date: Tue, 19 Nov 2024 16:06:24 +0100 Subject: [PATCH] Add cache manager image and helm chart --- .ci/pipeline_definitions | 15 +++++++ Dockerfile.extensions.cache-manager | 27 ++++++++++++ .../charts/cache-manager/Chart.yaml | 3 ++ .../templates/cache-manager.yaml | 42 +++++++++++++++++++ charts/extensions/values.yaml | 5 +++ setup.service.py | 1 + 6 files changed, 93 insertions(+) create mode 100644 Dockerfile.extensions.cache-manager create mode 100644 charts/extensions/charts/cache-manager/Chart.yaml create mode 100644 charts/extensions/charts/cache-manager/templates/cache-manager.yaml diff --git a/.ci/pipeline_definitions b/.ci/pipeline_definitions index d29339ed..bc9576d6 100644 --- a/.ci/pipeline_definitions +++ b/.ci/pipeline_definitions @@ -95,6 +95,13 @@ delivery-service: inputs: steps: build_python_packages: ~ + extension-cache-manager: &extension-cache-manager-image + image: europe-docker.pkg.dev/gardener-project/releases/ocm-gear/extension-cache-manager + dockerfile: Dockerfile.extensions.cache-manager + tag_as_latest: True + inputs: + steps: + build_python_packages: ~ extension-clamav: &extension-clamav-image image: europe-docker.pkg.dev/gardener-project/releases/ocm-gear/extension-clamav dockerfile: Dockerfile.extensions.clamav @@ -135,6 +142,10 @@ delivery-service: attribute: backlog-controller.issue-replicator.image.repository - ref: ocm-resource:extensions.tag attribute: backlog-controller.issue-replicator.image.tag + - ref: ocm-resource:extension-cache-manager.repository + attribute: cache-manager.image.repository + - ref: ocm-resource:extension-cache-manager.tag + attribute: cache-manager.image.tag - ref: ocm-resource:extensions.repository attribute: delivery-db-backup.image.repository - ref: ocm-resource:extensions.tag @@ -167,6 +178,10 @@ delivery-service: <<: *extensions-image tag_as_latest: False image: europe-docker.pkg.dev/gardener-project/snapshots/ocm-gear/extensions + extension-cache-manager: + <<: *extension-cache-manager-image + tag_as_latest: False + image: europe-docker.pkg.dev/gardener-project/snapshots/ocm-gear/extension-cache-manager extension-clamav: <<: *extension-clamav-image tag_as_latest: False diff --git a/Dockerfile.extensions.cache-manager b/Dockerfile.extensions.cache-manager new file mode 100644 index 00000000..423932aa --- /dev/null +++ b/Dockerfile.extensions.cache-manager @@ -0,0 +1,27 @@ +FROM ghcr.io/gardener/cc-utils/alpine:3 + +RUN --mount=type=bind,source=VERSION,target=/VERSION \ + --mount=type=bind,source=requirements.utils.txt,target=/requirements.utils.txt \ + --mount=type=bind,source=requirements.service.txt,target=/requirements.service.txt \ + --mount=type=bind,source=/dist,target=/dist \ + apk add --no-cache \ + bash \ + gcc \ + git \ + libc-dev \ + libffi-dev \ + postgresql16-client \ + python3 \ + python3-dev \ + py3-pip \ + py3-numpy \ + py3-scipy \ +&& mkdir -p $HOME/.config/pip \ +&& echo -e "[global]\nbreak-system-packages = true" >> $HOME/.config/pip/pip.conf \ +&& pip3 install --upgrade --no-cache-dir --find-links ./dist ocm-gear-service \ +&& apk del --no-cache \ + libc-dev \ + libffi-dev \ + python3-dev + +ENTRYPOINT ["python3", "-m", "cache_manager"] diff --git a/charts/extensions/charts/cache-manager/Chart.yaml b/charts/extensions/charts/cache-manager/Chart.yaml new file mode 100644 index 00000000..3428aed1 --- /dev/null +++ b/charts/extensions/charts/cache-manager/Chart.yaml @@ -0,0 +1,3 @@ +apiVersion: v2 +name: cache-manager +version: 0.1.0 diff --git a/charts/extensions/charts/cache-manager/templates/cache-manager.yaml b/charts/extensions/charts/cache-manager/templates/cache-manager.yaml new file mode 100644 index 00000000..7a26b746 --- /dev/null +++ b/charts/extensions/charts/cache-manager/templates/cache-manager.yaml @@ -0,0 +1,42 @@ +{{- range $config := .Values.configurations }} +apiVersion: batch/v1 +kind: CronJob +metadata: + name: {{ $name := print "cache-manager-" $config.envVars.CFG_NAME }}{{ $name }} +spec: + schedule: {{ default "0 * * * *" $config.schedule | quote }} # schedule contains asterisks, quote to avoid yaml parser errors + concurrencyPolicy: Forbid + successfulJobsHistoryLimit: {{ default 1 $config.successfulJobsHistoryLimit }} + failedJobsHistoryLimit: {{ default 1 $config.failedJobsHistoryLimit }} + jobTemplate: + spec: + template: + metadata: + labels: + app: cache-manager + spec: + containers: + - name: cache-manager + image: {{ include "image" $.Values.image }} + imagePullPolicy: IfNotPresent + command: + - python3 + - -m + - cache_manager + env: + {{- range $key, $value := $config.envVars }} + - name: {{ $key }} + value: {{ $value }} + {{- end }} + volumeMounts: + - name: cfg-factory + mountPath: "/cfg_factory" + readOnly: true + volumes: + - name: cfg-factory + secret: + secretName: cfg-factory-secret + optional: true + restartPolicy: Never +--- +{{- end }} diff --git a/charts/extensions/values.yaml b/charts/extensions/values.yaml index 966deaa7..cd36b469 100644 --- a/charts/extensions/values.yaml +++ b/charts/extensions/values.yaml @@ -21,6 +21,11 @@ backlog-controller: image: # image property will be set during release repository: ~ tag: ~ +cache-manager: + enabled: false + image: # image property will be set during release + repository: ~ + tag: ~ delivery-db-backup: enabled: false image: # image property will be set during release diff --git a/setup.service.py b/setup.service.py index 57bd67a5..59bd7b45 100644 --- a/setup.service.py +++ b/setup.service.py @@ -24,6 +24,7 @@ def modules(): return [ 'app', 'artefacts', + 'cache_manager', 'compliance_tests', 'components', 'dora',