homelab/k3s/n8n/n8n-db-init.yaml
Samantha Atkins 759ef949bc K3s cluster on Proxmox with WireGuard mesh networking
Replaced Headscale (too buggy in 0.28.x — random node drops) with direct
WireGuard hub-and-spoke + full mesh. 7 Proxmox VMs across 3 hosts form a
K3s v1.34.6 cluster: 3 control-plane/etcd nodes, 4 workers.

Running services: postgres, mariadb, ghost (x3), forgejo, authentik.
All unpinned services use local-path StorageClass. Databases pinned to
pve-worker and adder-worker with local PVs.

Includes VM provisioning scripts (create-debian-template.sh, clone-vm.sh),
K3s manifests for all services, and full deployment docs in k3s/README.md.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 01:23:13 -04:00

44 lines
1.1 KiB
YAML

# n8n DB Init Job
# Creates n8n database and user in PostgreSQL.
# Run once before deploying n8n.
#
# Deploy:
# kubectl create secret generic n8n-secret \
# --namespace <ns> \
# --from-literal=db-password='<password>'
# kubectl apply -f n8n-db-init.yaml -n <ns>
#
# Watch completion:
# kubectl get jobs -n <ns> -w
# kubectl logs job/n8n-db-init -n <ns>
apiVersion: batch/v1
kind: Job
metadata:
name: n8n-db-init
spec:
template:
spec:
restartPolicy: OnFailure
containers:
- name: n8n-db-init
image: postgres:16
env:
- name: PGPASSWORD
valueFrom:
secretKeyRef:
name: postgres-secret
key: password
- name: N8N_DB_PASSWORD
valueFrom:
secretKeyRef:
name: n8n-secret
key: db-password
command:
- /bin/sh
- -c
- |
psql -h postgres -U postgres <<EOF
CREATE USER n8n_user WITH PASSWORD '${N8N_DB_PASSWORD}';
CREATE DATABASE n8n_db OWNER n8n_user;
EOF