homek8s/apps/base/sirius-growth/cronjob-leadgen.yaml
Sirius DevOps bc942e2571 registry(auth): require auth for image pulls (audit F11)
Forgejo 16 mints an anonymous ("ghost user") registry token on /v2/token and
grants it Read on every package regardless of repo visibility, so all 18 app
images were world-downloadable — including images of private repos
(siriusdevops-site, phs-site, sirius-growth-*, sgs-leadgen).

* FORGEJO__service__REQUIRE_SIGNIN_VIEW=true: /v2/token answers UNAUTHORIZED
  to anonymous clients, anonymous manifests get 401. This is the documented
  switch in routers/api/packages/container (Authenticate) and
  services/context/package.go (determineAccessMode). Side effect: the Forgejo
  web UI/API becomes login-only for anonymous visitors.
* imagePullSecrets: [forgejo-pull] on all 18 workloads that pull from the
  registry (osint, piedmont, sirius-growth, siriusdevops). The
  kubernetes.io/dockerconfigjson Secret is per-namespace and out of band
  (never in git); docs/registry-pull-auth.md documents why, how to recreate
  it, and the verification commands. No containerd-level credential.
2026-11-27 00:15:20 -05:00

87 lines
2.8 KiB
YAML

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:
imagePullSecrets:
- name: forgejo-pull
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