From ac43ac65fb743c7df530cfa9038892667bb8a2c9 Mon Sep 17 00:00:00 2001 From: Florian Wilhelm <2292245+fwilhe@users.noreply.github.com> Date: Wed, 18 Sep 2024 15:41:15 +0200 Subject: [PATCH] Add ingest cronjob (#111) Run ingestion as cronjob to update the database Fixes https://github.com/gardenlinux/glvd/issues/102 --- 02_ingestion-job.yaml | 71 +++++++++++++++++++++++++++++++++++++++++++ deploy-k8s.sh | 1 + 2 files changed, 72 insertions(+) create mode 100644 02_ingestion-job.yaml diff --git a/02_ingestion-job.yaml b/02_ingestion-job.yaml new file mode 100644 index 0000000..574f5f2 --- /dev/null +++ b/02_ingestion-job.yaml @@ -0,0 +1,71 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: glvd-ingestion + labels: + app.kubernetes.io/name: glvd + gardenlinux.io/glvd-component: glvd-ingestion +data: + databaseName: glvd + databaseHost: glvd-database-0.glvd-database + databasePort: "5432" +--- +apiVersion: batch/v1 +kind: CronJob +metadata: + name: glvd-ingestion + labels: + app.kubernetes.io/name: glvd + gardenlinux.io/glvd-component: glvd-ingestion +spec: + schedule: "30 8 * * 1-5" + timeZone: "Europe/Berlin" + jobTemplate: + metadata: + labels: + app.kubernetes.io/name: glvd + gardenlinux.io/glvd-component: glvd-ingestion + spec: + template: + spec: + restartPolicy: Never + containers: + - name: data-ingestion + image: ghcr.io/gardenlinux/glvd-data-ingestion:edge + # resources: + # requests: + # cpu: "1" + # memory: "2Gi" + # limits: + # cpu: "2" + # memory: "4Gi" + command: + - /bin/bash + - -c + - sleep 5 && echo start && /usr/local/src/ingest-postgres.sh + env: + - name: PGDATABASE + valueFrom: + configMapKeyRef: + name: glvd-ingestion + key: databaseName + - name: PGUSER + valueFrom: + secretKeyRef: + name: postgres-credentials + key: username + - name: PGPASSWORD + valueFrom: + secretKeyRef: + name: postgres-credentials + key: password + - name: PGHOST + valueFrom: + configMapKeyRef: + name: glvd-ingestion + key: databaseHost + - name: PGPORT + valueFrom: + configMapKeyRef: + name: glvd-ingestion + key: databasePort diff --git a/deploy-k8s.sh b/deploy-k8s.sh index 19548ee..b1a71d3 100755 --- a/deploy-k8s.sh +++ b/deploy-k8s.sh @@ -13,3 +13,4 @@ kubectl run init-pg --image=ghcr.io/gardenlinux/glvd-postgres-init:latest --rest sleep 60 kubectl apply -f 01_glvd-deployment.yaml +kubectl apply -f 02_ingestion-job.yaml