Add ability to create dbs
This commit is contained in:
parent
887424946f
commit
268b4693cf
17
infrastructure/postgres/create-db.sh
Executable file
17
infrastructure/postgres/create-db.sh
Executable file
@ -0,0 +1,17 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
SUBJECT=$1
|
||||||
|
PGPASSWORD=$2
|
||||||
|
|
||||||
|
PASSWORD=$(openssl rand -hex 20)
|
||||||
|
ID=$(openssl rand -hex 5)
|
||||||
|
|
||||||
|
kubectl run "postgres-client-$ID" --rm -i --image "bitnami/postgresql" -n postgres --env="PGPASSWORD=$PGPASSWORD" --command -- psql --host postgres-postgresql -U postgres <<SQL
|
||||||
|
CREATE DATABASE $SUBJECT;
|
||||||
|
CREATE USER $SUBJECT with encrypted password '$PASSWORD';
|
||||||
|
grant all privileges on database $SUBJECT to $SUBJECT;
|
||||||
|
SQL
|
||||||
|
|
||||||
|
echo "$PASSWORD"
|
7
infrastructure/postgres/port-forward-db.sh
Executable file
7
infrastructure/postgres/port-forward-db.sh
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
PGPASSWORD=$1
|
||||||
|
|
||||||
|
kubectl run postgres-client --rm --tty -i --image "bitnami/postgresql" -n postgres --env="PGPASSWORD=$PGPASSWORD" --command -- psql --host postgres-postgresql -U postgres
|
Loading…
Reference in New Issue
Block a user