27 lines
906 B
Bash
Executable File
27 lines
906 B
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
NAMESPACE="shorefront"
|
|
|
|
# --- Preflight checks ---
|
|
if ! command -v kubectl &>/dev/null; then
|
|
echo "Error: kubectl is not installed or not in PATH" >&2
|
|
exit 1
|
|
fi
|
|
|
|
# --- Validate required env vars ---
|
|
: "${POSTGRES_PASSWORD:?POSTGRES_PASSWORD is required}"
|
|
: "${JWT_SECRET_KEY:?JWT_SECRET_KEY is required}"
|
|
|
|
echo "Creating namespace '${NAMESPACE}' if it does not exist..."
|
|
kubectl create namespace "${NAMESPACE}" --dry-run=client -o yaml | kubectl apply -f -
|
|
|
|
echo "Creating/updating secret 'shorefront-secret' in namespace '${NAMESPACE}'..."
|
|
kubectl create secret generic shorefront-secret \
|
|
--namespace "${NAMESPACE}" \
|
|
--from-literal="POSTGRES_PASSWORD=${POSTGRES_PASSWORD}" \
|
|
--from-literal="JWT_SECRET_KEY=${JWT_SECRET_KEY}" \
|
|
--dry-run=client -o yaml | kubectl apply -f -
|
|
|
|
echo "Done. Secret 'shorefront-secret' is ready in namespace '${NAMESPACE}'."
|