Files
server/bin/secret-push
2024-10-06 16:00:18 -04:00

29 lines
503 B
Bash
Executable File

#!/bin/bash
SCRIPT_DIR="$(dirname -- "$( readlink -f -- "$0"; )";)"
CONF_DIR="$SCRIPT_DIR/.."
if [ "$1" == "" ]; then
echo 'usage: secret-push {config_name} [secret_name]'
exit 1
fi
CONFIG=$1
shift
if [ "$1" != "" ]; then
KEY=server-secret-$1
else
KEY=server-secret
fi
FILE="$CONF_DIR/.env-$CONFIG"
if [ ! -f "$FILE" ]; then
echo Could not find env file for $FILE
exit 1;
fi
kubectl create secret generic "$KEY" --from-file ".env=$FILE" --dry-run=client -o yaml | kubectl apply -f -