How do you seed initial data on first deployment only?
Short answer
Use a PreSync or Sync hook Job with BeforeHookCreation deletion and idempotent seeding logic, or gate it so re-runs are no-ops. Because hooks run each sync, the seed script itself should detect existing data and skip, giving effectively run-once behavior safely.
Advertisement
AModel answer
Use a PreSync or Sync hook Job with BeforeHookCreation deletion and idempotent seeding logic, or gate it so re-runs are no-ops. Because hooks run each sync, the seed script itself should detect existing data and skip, giving effectively run-once behavior safely.
metadata:
annotations:
argocd.argoproj.io/hook: PostSync
argocd.argoproj.io/hook-delete-policy: HookSucceededReal-world example
A seed Job checks whether the table is populated and exits early on subsequent syncs.
Likely follow-ups
- How do you make seeding idempotent? | Why can't you assume run-once?
Related topics