Files
infrastructure/servers/legion/k8s/redpanda/topics-job.yaml
Will Anderson 2d655e0966 fix backup-verify path and suspend redpanda-topics-init
backup-verify: restic restores /dump/all-databases.sql relative to
restore target, so the check path was wrong (/all-databases.sql →
/dump/all-databases.sql). Also fix the --include filter to match.

redpanda-topics-init: redpanda is intentionally scaled to 0; the init
job will block forever waiting for a broker. Mark it suspended so Argo
CD won't keep creating a stuck job. Re-enable when redpanda is turned on.
2026-05-04 10:54:31 -05:00

64 lines
2.4 KiB
YAML

---
# One-time job to create Neuron Kafka topics in Redpanda.
# Runs on startup; idempotent (rpk topic create is a no-op if topic already exists).
# Argo CD will re-apply if deleted; ttlSecondsAfterFinished cleans it up automatically.
apiVersion: batch/v1
kind: Job
metadata:
name: redpanda-topics-init
namespace: redpanda
spec:
suspend: true # redpanda is scaled to 0; unsuspend this when redpanda is re-enabled
ttlSecondsAfterFinished: 300
template:
spec:
restartPolicy: OnFailure
initContainers:
- name: wait-for-redpanda
image: docker.redpanda.com/redpandadata/redpanda:latest
command:
- sh
- -c
- |
echo "Waiting for Redpanda to be ready..."
until rpk cluster info --brokers=redpanda.redpanda.svc.cluster.local:9092 >/dev/null 2>&1; do
echo "Redpanda not ready, retrying in 5s..."
sleep 5
done
echo "Redpanda is ready."
containers:
- name: create-topics
image: docker.redpanda.com/redpandadata/redpanda:latest
command:
- sh
- -c
- |
BROKER=redpanda.redpanda.svc.cluster.local:9092
echo "Creating neuron.swarm (retention 7 days)..."
rpk topic create neuron.swarm \
--brokers "$BROKER" \
--topic-config retention.ms=604800000 \
|| echo "neuron.swarm already exists, skipping"
echo "Creating neuron.ci (retention 3 days)..."
rpk topic create neuron.ci \
--brokers "$BROKER" \
--topic-config retention.ms=259200000 \
|| echo "neuron.ci already exists, skipping"
echo "Creating neuron.vcs (retention 3 days)..."
rpk topic create neuron.vcs \
--brokers "$BROKER" \
--topic-config retention.ms=259200000 \
|| echo "neuron.vcs already exists, skipping"
echo "Creating neuron.webhooks (retention 1 day)..."
rpk topic create neuron.webhooks \
--brokers "$BROKER" \
--topic-config retention.ms=86400000 \
|| echo "neuron.webhooks already exists, skipping"
echo "Topic init complete."
rpk topic list --brokers "$BROKER"