All K8s nodeSelectors, CI config, runner config, monitoring docs, and smoke tests now reference the new pool names provisioned by terragrunt. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
64 lines
2.2 KiB
YAML
64 lines
2.2 KiB
YAML
apiVersion: batch/v1
|
|
kind: Job
|
|
metadata:
|
|
name: gitlab-postgres-init
|
|
namespace: foxhunt
|
|
labels:
|
|
app.kubernetes.io/name: gitlab-postgres-init
|
|
app.kubernetes.io/part-of: foxhunt
|
|
spec:
|
|
ttlSecondsAfterFinished: 300
|
|
backoffLimit: 3
|
|
template:
|
|
spec:
|
|
nodeSelector:
|
|
k8s.scaleway.com/pool-name: services
|
|
restartPolicy: Never
|
|
containers:
|
|
- name: init
|
|
image: timescale/timescaledb:latest-pg16
|
|
command:
|
|
- bash
|
|
- -c
|
|
- |
|
|
set -euo pipefail
|
|
export PGPASSWORD="$POSTGRES_PASSWORD"
|
|
|
|
until pg_isready -h postgres -U foxhunt; do
|
|
echo "Waiting for postgres..."
|
|
sleep 2
|
|
done
|
|
|
|
echo "Creating gitlab user..."
|
|
psql -h postgres -U foxhunt -d foxhunt -tc \
|
|
"SELECT 1 FROM pg_roles WHERE rolname='gitlab'" | grep -q 1 || \
|
|
psql -h postgres -U foxhunt -d foxhunt -c \
|
|
"CREATE ROLE gitlab WITH LOGIN PASSWORD '${GITLAB_DB_PASSWORD}'"
|
|
|
|
echo "Creating gitlab database..."
|
|
psql -h postgres -U foxhunt -tc \
|
|
"SELECT 1 FROM pg_database WHERE datname='gitlab'" | grep -q 1 || \
|
|
psql -h postgres -U foxhunt -c \
|
|
"CREATE DATABASE gitlab OWNER gitlab"
|
|
|
|
echo "Creating extensions..."
|
|
psql -h postgres -U foxhunt -d gitlab -c "CREATE EXTENSION IF NOT EXISTS pg_trgm;"
|
|
psql -h postgres -U foxhunt -d gitlab -c "CREATE EXTENSION IF NOT EXISTS btree_gist;"
|
|
|
|
echo "Granting permissions..."
|
|
psql -h postgres -U foxhunt -d gitlab -c "GRANT ALL PRIVILEGES ON DATABASE gitlab TO gitlab;"
|
|
psql -h postgres -U foxhunt -d gitlab -c "GRANT ALL ON SCHEMA public TO gitlab;"
|
|
|
|
echo "GitLab database initialized successfully."
|
|
env:
|
|
- name: POSTGRES_PASSWORD
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: foxhunt-secrets
|
|
key: db-password
|
|
- name: GITLAB_DB_PASSWORD
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: gitlab-secrets
|
|
key: db-password
|