This commit is contained in:
2023-11-09 17:57:55 +01:00
parent ef84704340
commit 0eb133cede
5 changed files with 83 additions and 21 deletions

View File

@ -0,0 +1,33 @@
#!/bin/bash
. ~/Workspace/MyKubernetesEnv/ENVDB
DATABASE=cem_monitoring_berresheim
LOGIN=cem_preprocessor
PASSWORD=`openssl rand -base64 24`
NAMESPACE=`cat namespace`
psql <<EOF
do
\$\$
begin
if not exists (SELECT * FROM pg_user WHERE usename = '$LOGIN') then
CREATE USER $LOGIN WITH PASSWORD '$PASSWORD';
else
ALTER USER $LOGIN WITH PASSWORD '$PASSWORD';
end if;
end
\$\$
;
commit;
EOF
kubectl create secret generic cemmetering-db-cred \
--dry-run=client \
-o yaml \
--save-config \
--from-literal=PGUSER="$LOGIN" \
--from-literal=PGPASSWORD="$PASSWORD" | \
kubectl apply -f - -n $NAMESPACE