Skip to content

Commit

Permalink
add db init script
Browse files Browse the repository at this point in the history
  • Loading branch information
fwilhe committed Sep 24, 2024
1 parent 733ed8e commit e9a5ef7
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions init-db.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

# Quick and dirty script to apply a new db dump to the glvd instance
# Obtain image digest from https://github.com/gardenlinux/glvd-contrib/actions/workflows/pg-init.yaml

if [[ "$#" -ne 1 ]]; then
echo "Usage: $(basename "$0") <image-digest-sha>"
exit 1
fi

SHA=$1

kubectl scale --replicas=0 deploy/glvd
kubectl delete po/init-pg
DB_PASSWORD=$(kubectl get secret/postgres-credentials --template="{{.data.password}}" | base64 -d)
kubectl run init-pg --image=ghcr.io/gardenlinux/glvd-postgres-init:latest@sha256:"$SHA" --restart=Never --env=PGHOST=glvd-database-0.glvd-database --env=PGPASSWORD="$DB_PASSWORD"
sleep 40
kubectl logs po/init-pg
sleep 10
kubectl scale --replicas=1 deploy/glvd

0 comments on commit e9a5ef7

Please sign in to comment.