All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
48 lines
1.1 KiB
Bash
Executable File
48 lines
1.1 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
FILE=$1
|
|
if [ "$FILE" = "" ]; then
|
|
echo "give config file to load as first argument"
|
|
exit 1
|
|
fi
|
|
SECRET_NAME=$2
|
|
if [ "$SECRET_NAME" = "" ]; then
|
|
echo "give secret name to create/modify as second argument"
|
|
exit 1
|
|
fi
|
|
NAMESPACE=$3
|
|
if [ "$NAMESPACE" = "" ]; then
|
|
echo "give namespace as third argument"
|
|
exit 1
|
|
fi
|
|
|
|
kubectl create secret generic $SECRET_NAME \
|
|
--from-literal=UDI_CONF="`cat $FILE`" \
|
|
-n $NAMESPACE \
|
|
--dry-run=client \
|
|
-o yaml \
|
|
--save-config | \
|
|
kubectl apply -f -
|
|
|
|
. ~/Workspace/MyKubernetesEnv/ENVDB
|
|
DATABASE=udi
|
|
LOGIN=udi
|
|
PASSWORD=`openssl rand -base64 24`
|
|
psql <<EOF
|
|
ALTER USER $LOGIN WITH PASSWORD '$PASSWORD';
|
|
GRANT ALL PRIVILEGES ON DATABASE $DATABASE TO $LOGIN;
|
|
COMMIT;
|
|
EOF
|
|
|
|
kubectl create secret generic udi-db-cred \
|
|
--dry-run=client \
|
|
-o yaml \
|
|
--save-config \
|
|
--from-literal=PGUSER="$LOGIN" \
|
|
--from-literal=PGHOST="timescaledb.database.svc.cluster.local" \
|
|
--from-literal=PGPASSWORD="$PASSWORD" \
|
|
--from-literal=PGSSLMODE="require" \
|
|
--from-literal=PGDATABASE="$DATABASE" | \
|
|
kubectl apply -f - -n $NAMESPACE
|
|
|