fix: remove destructive initContainer, use one-time Argo CD hook Job for schema install

This commit is contained in:
Will Anderson
2026-04-04 18:57:36 -05:00
parent 0b8eb4264a
commit 58eea3b686
2 changed files with 46 additions and 34 deletions
@@ -0,0 +1,46 @@
---
# One-time job to install the listmonk database schema.
# WARNING: --install wipes and recreates tables. Only run on fresh DB.
# This job has a unique name with a timestamp suffix to prevent re-running.
# After first successful run it completes and TTL cleans it up.
# To re-install schema (destructive): delete this job and re-apply.
apiVersion: batch/v1
kind: Job
metadata:
name: listmonk-schema-init-v1
namespace: listmonk
annotations:
# Prevent Argo CD from pruning a completed job
argocd.argoproj.io/hook: Sync
argocd.argoproj.io/hook-delete-policy: HookSucceeded
spec:
ttlSecondsAfterFinished: 600
template:
spec:
restartPolicy: OnFailure
containers:
- name: listmonk-install
image: listmonk/listmonk:v4.1.0
command: ["/bin/sh", "-c", "cd /listmonk && ./listmonk --install --yes"]
env:
- name: LISTMONK_db__host
value: "postgres-postgresql.platform.svc.cluster.local"
- name: LISTMONK_db__port
value: "5432"
- name: LISTMONK_db__name
valueFrom:
secretKeyRef:
name: listmonk-secrets
key: db_name
- name: LISTMONK_db__user
valueFrom:
secretKeyRef:
name: listmonk-secrets
key: db_user
- name: LISTMONK_db__password
valueFrom:
secretKeyRef:
name: listmonk-secrets
key: db_password
- name: LISTMONK_db__ssl_mode
value: "disable"