fix
This commit is contained in:
33
deployment/roll-db-credential.sh
Executable file
33
deployment/roll-db-credential.sh
Executable 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
|
||||
|
||||
|
Reference in New Issue
Block a user