From 45c3b8533b3d66b9cdcbd6cd06eccc02b8451a16 Mon Sep 17 00:00:00 2001 From: Lance Walters Date: Tue, 3 Nov 2026 12:46:27 -0500 Subject: [PATCH] apps(sirius-growth): sgs-leadgen weekly CronJob (ET) + monthly NCDA job + state PVC Runs the published amd64 image forgejo.../sgs-leadgen:eef9358 with DATABASE_URL from sirius-growth-portal-app and the contact bot's Telegram pair; /data on a local-path PVC pins to siriussec, /tmp on an emptyDir so the root fs stays RO. --- .../sirius-growth/cronjob-leadgen-ncda.yaml | 85 +++++++++++++++++++ apps/base/sirius-growth/cronjob-leadgen.yaml | 85 +++++++++++++++++++ apps/base/sirius-growth/kustomization.yaml | 3 + apps/base/sirius-growth/pvc-leadgen.yaml | 12 +++ 4 files changed, 185 insertions(+) create mode 100644 apps/base/sirius-growth/cronjob-leadgen-ncda.yaml create mode 100644 apps/base/sirius-growth/cronjob-leadgen.yaml create mode 100644 apps/base/sirius-growth/pvc-leadgen.yaml diff --git a/apps/base/sirius-growth/cronjob-leadgen-ncda.yaml b/apps/base/sirius-growth/cronjob-leadgen-ncda.yaml new file mode 100644 index 0000000..898e058 --- /dev/null +++ b/apps/base/sirius-growth/cronjob-leadgen-ncda.yaml @@ -0,0 +1,85 @@ +apiVersion: batch/v1 +kind: CronJob +metadata: + name: sgs-leadgen-ncda + namespace: sirius-growth +spec: + # 10:00, not 08:00: on a Monday-the-1st the weekly job owns the RWO volume at + # 08:00 and concurrencyPolicy is per-CronJob, so a 2h gap keeps them apart. + schedule: "0 10 1 * *" + timeZone: America/New_York + concurrencyPolicy: Forbid + startingDeadlineSeconds: 3600 + suspend: false + successfulJobsHistoryLimit: 3 + failedJobsHistoryLimit: 3 + jobTemplate: + spec: + backoffLimit: 1 + activeDeadlineSeconds: 1800 + ttlSecondsAfterFinished: 604800 + template: + metadata: + labels: + app: sgs-leadgen-ncda + spec: + restartPolicy: Never + nodeSelector: + kubernetes.io/hostname: siriussec + tolerations: + - key: dedicated + operator: Exists + effect: PreferNoSchedule + securityContext: + fsGroup: 10001 + containers: + - name: leadgen + image: forgejo.siriusdevops.com/sirius/sgs-leadgen:eef935874bb19b6cee73bd93d7fd9ab4001ec184 + imagePullPolicy: IfNotPresent + env: + - name: DATABASE_URL + valueFrom: + secretKeyRef: + name: sirius-growth-portal-app + key: database-url + - name: TELEGRAM_BOT_TOKEN + valueFrom: + secretKeyRef: + name: sirius-growth-contact + key: TG_TOKEN + - name: TELEGRAM_CHAT_ID + valueFrom: + secretKeyRef: + name: sirius-growth-contact + key: TG_CHAT + - name: SGS_DATA_DIR + value: /data + - name: SGS_STATE_PATH + value: /data/state.json + - name: SGS_CSV + value: /data/leads.csv + # Monthly-only source: the NCDA&CS licensed-nursery register. + - name: SGS_NCDA + value: "1" + volumeMounts: + - name: data + mountPath: /data + - name: tmp + mountPath: /tmp + securityContext: + runAsNonRoot: true + allowPrivilegeEscalation: false + readOnlyRootFilesystem: true + resources: + requests: + cpu: 100m + memory: 256Mi + limits: + memory: 1Gi + volumes: + - name: data + persistentVolumeClaim: + claimName: sgs-leadgen-data + - name: tmp + emptyDir: + sizeLimit: 256Mi diff --git a/apps/base/sirius-growth/cronjob-leadgen.yaml b/apps/base/sirius-growth/cronjob-leadgen.yaml new file mode 100644 index 0000000..051bfca --- /dev/null +++ b/apps/base/sirius-growth/cronjob-leadgen.yaml @@ -0,0 +1,85 @@ +apiVersion: batch/v1 +kind: CronJob +metadata: + name: sgs-leadgen + namespace: sirius-growth +spec: + schedule: "0 8 * * 1" + timeZone: America/New_York + concurrencyPolicy: Forbid + startingDeadlineSeconds: 3600 + suspend: false + successfulJobsHistoryLimit: 3 + failedJobsHistoryLimit: 3 + jobTemplate: + spec: + backoffLimit: 1 + activeDeadlineSeconds: 1800 + ttlSecondsAfterFinished: 604800 + template: + metadata: + labels: + app: sgs-leadgen + spec: + restartPolicy: Never + # local-path is a node-local volume: the pod must run where the PV is. + nodeSelector: + kubernetes.io/hostname: siriussec + tolerations: + - key: dedicated + operator: Exists + effect: PreferNoSchedule + # local-path mounts root-owned; the image runs as uid 10001, so fsGroup + # makes /data group-writable for it. + securityContext: + fsGroup: 10001 + containers: + - name: leadgen + image: forgejo.siriusdevops.com/sirius/sgs-leadgen:eef935874bb19b6cee73bd93d7fd9ab4001ec184 + imagePullPolicy: IfNotPresent + env: + - name: DATABASE_URL + valueFrom: + secretKeyRef: + name: sirius-growth-portal-app + key: database-url + - name: TELEGRAM_BOT_TOKEN + valueFrom: + secretKeyRef: + name: sirius-growth-contact + key: TG_TOKEN + - name: TELEGRAM_CHAT_ID + valueFrom: + secretKeyRef: + name: sirius-growth-contact + key: TG_CHAT + - name: SGS_DATA_DIR + value: /data + - name: SGS_STATE_PATH + value: /data/state.json + - name: SGS_CSV + value: /data/leads.csv + volumeMounts: + - name: data + mountPath: /data + # tempfile.NamedTemporaryFile() needs a writable TMPDIR; the rest + # of the root filesystem stays read-only. + - name: tmp + mountPath: /tmp + securityContext: + runAsNonRoot: true + allowPrivilegeEscalation: false + readOnlyRootFilesystem: true + resources: + requests: + cpu: 100m + memory: 256Mi + limits: + memory: 1Gi + volumes: + - name: data + persistentVolumeClaim: + claimName: sgs-leadgen-data + - name: tmp + emptyDir: + sizeLimit: 256Mi diff --git a/apps/base/sirius-growth/kustomization.yaml b/apps/base/sirius-growth/kustomization.yaml index c408e84..ab9f9d8 100644 --- a/apps/base/sirius-growth/kustomization.yaml +++ b/apps/base/sirius-growth/kustomization.yaml @@ -11,3 +11,6 @@ resources: - httproute.yaml - cluster.yaml - podmonitor.yaml + - pvc-leadgen.yaml + - cronjob-leadgen.yaml + - cronjob-leadgen-ncda.yaml diff --git a/apps/base/sirius-growth/pvc-leadgen.yaml b/apps/base/sirius-growth/pvc-leadgen.yaml new file mode 100644 index 0000000..a0fc253 --- /dev/null +++ b/apps/base/sirius-growth/pvc-leadgen.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: sgs-leadgen-data + namespace: sirius-growth +spec: + accessModes: + - ReadWriteOnce + storageClassName: local-path + resources: + requests: + storage: 1Gi