05 — jobGroups (Job + CronJob)
Two jobGroups in one release:
migrations—kind: Job, runs as aPreSynchook on every Argo CD sync. Tasks-mode: two ordered initContainers (01-structurethen02-seed) inside one Job.nightly—kind: CronJobwith two scheduled jobs sharing image and env:cleanupat 02:00 UTC andreportat 06:00 UTC.
What this shows
- Group-level config (
image,envSecrets,hooks) cascades into every job injobs:. Per-job fields override. - Tasks mode: a job whose work is split across multiple ordered initContainers, then a tiny “completed” container marks the Job successful. Useful for migration → seed pipelines where step ordering matters. Kubernetes runs
initContainerssequentially in their declared order, and the chart emits thetasksmap sorted alphabetically — so when ordering matters, prefix task names with01-,02-,03-etc. to make the run order explicit. (See ADR 014.) - Single-container mode (
command/argsdirectly on the job) for the CronJob members. - Hash-suffixed Job names (
<release>-migrations-schema-<sha8>) — the Job re-runs only when its rendered spec changes (image bump, env change, command edit). Argo CD on a 1-minute sync interval is harmless. (ADR 012) - Argo CD hook annotations on the migrations group → Argo CD treats those Jobs as PreSync hooks; the user-visible workloads continue applying once the hook completes.
- CronJob fields (
schedule,timeZone,concurrencyPolicy, history limits) live per job — different schedules per job in the same group.
Delta from 01-minimal
| Added | What |
|---|---|
jobGroups.migrations | Pre-sync schema migration via tasks-mode initContainers. |
jobGroups.nightly | Two CronJobs sharing image/env, different schedules. |
| Argo CD hooks | Migrations group runs as PreSync with syncWave: -2. |
| External Secret reference | db-credentials Secret carries DB_PASSWORD for migrations. |
(There is no Deployment in this example — purely batch workloads.)
Files
| File | Purpose |
|---|---|
values.yaml | Chart values. |
argocd/application.yaml | Argo CD Application, single source. |
argocd/application-multisource.yaml | Argo CD Application with spec.sources[]. |
flux/ocirepository.yaml | Flux OCIRepository. |
flux/helmrelease.yaml | Flux HelmRelease. |
helm/install.sh | Plain helm upgrade --install. |
Try it
# Pre-create the credentials Secret
kubectl create namespace batch
kubectl create secret generic db-credentials \
--from-literal=DB_PASSWORD='changeme' \
-n batch
bash helm/install.sh