apiVersion: batch/v1 kind: Job metadata: name: init-database namespace: lahuasca spec: backoffLimit: 4 template: spec: restartPolicy: Never containers: - name: init-db image: postgres:15 command: - sh - -ec - | until pg_isready -h "${DB_HOST}" -p "${DB_PORT}" -U "$POSTGRES_USER"; do echo "Waiting for postgres..." sleep 2 done psql \ -h "${DB_HOST}" \ -p "${DB_PORT}" \ -U "$POSTGRES_USER" \ -d "$POSTGRES_DB" \ -f /bootstrap/schema.sql sh /bootstrap/seed.sh echo "Database initialization completed!" env: - name: DB_HOST value: postgres - name: DB_PORT value: "5432" - name: PGPASSWORD valueFrom: secretKeyRef: name: la-huasca-db-secrets key: POSTGRES_PASSWORD - name: POSTGRES_USER valueFrom: secretKeyRef: name: la-huasca-db-secrets key: POSTGRES_USER - name: POSTGRES_DB valueFrom: secretKeyRef: name: la-huasca-db-secrets key: POSTGRES_DB - name: BOOTSTRAP_ADMIN_USERNAME valueFrom: secretKeyRef: name: la-huasca-bootstrap-secrets key: BOOTSTRAP_ADMIN_USERNAME - name: BOOTSTRAP_ADMIN_PASSWORD valueFrom: secretKeyRef: name: la-huasca-bootstrap-secrets key: BOOTSTRAP_ADMIN_PASSWORD - name: BOOTSTRAP_USER_USERNAME valueFrom: secretKeyRef: name: la-huasca-bootstrap-secrets key: BOOTSTRAP_USER_USERNAME - name: BOOTSTRAP_USER_PASSWORD valueFrom: secretKeyRef: name: la-huasca-bootstrap-secrets key: BOOTSTRAP_USER_PASSWORD - name: BOOTSTRAP_WIFI_PASSWORD valueFrom: secretKeyRef: name: la-huasca-bootstrap-secrets key: BOOTSTRAP_WIFI_PASSWORD - name: BOOTSTRAP_TAGLINE valueFrom: configMapKeyRef: name: la-huasca-bootstrap-config key: BOOTSTRAP_TAGLINE volumeMounts: - name: bootstrap mountPath: /bootstrap readOnly: true volumes: - name: bootstrap configMap: name: la-huasca-bootstrap-config defaultMode: 0755 items: - key: schema.sql path: schema.sql - key: seed.sh path: seed.sh