homelab/k3s/forgejo/forgejo-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

43 lines
1.1 KiB
YAML

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