Files
Kubernetes/Ollama/create_openwebui_secret.sh
T

40 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
set -euo pipefail
# Helper script to create the openwebui-secret without committing passwords.
# Run interactively and enter the password when prompted.
NAMESPACE="ollama"
SECRET_NAME="openwebui-secret"
echo "=== Create Kubernetes secret for Open WebUI ==="
read -rsp "Enter password for the 'openwebui' PostgreSQL user: " DB_PASSWORD
echo
read -rsp "Enter WEBUI_SECRET_KEY (or press Enter to auto-generate one): " SECRET_KEY
echo
if [[ -z "$SECRET_KEY" ]]; then
SECRET_KEY=$(openssl rand -hex 32)
echo "Auto-generated WEBUI_SECRET_KEY: $SECRET_KEY"
fi
read -rp "Enter Open WebUI admin email [admin@mariushome.lt]: " ADMIN_EMAIL
ADMIN_EMAIL=${ADMIN_EMAIL:-admin@mariushome.lt}
read -rsp "Enter Open WebUI admin password [fsbubSHADBJKASDs4s4ds5]: " ADMIN_PASSWORD
echo
ADMIN_PASSWORD=${ADMIN_PASSWORD:-fsbubSHADBJKASDs4s4ds5}
DATABASE_URL="postgresql://openwebui:${DB_PASSWORD}@postgres-hetzner.database.svc.cluster.local:5432/openwebui"
PGVECTOR_DB_URL="postgresql://openwebui:${DB_PASSWORD}@postgres-hetzner.database.svc.cluster.local:5432/openwebui"
kubectl create secret generic -n "$NAMESPACE" "$SECRET_NAME" \
--from-literal=WEBUI_SECRET_KEY="$SECRET_KEY" \
--from-literal=WEBUI_ADMIN_EMAIL="$ADMIN_EMAIL" \
--from-literal=WEBUI_ADMIN_PASSWORD="$ADMIN_PASSWORD" \
--from-literal=DATABASE_URL="$DATABASE_URL" \
--from-literal=PGVECTOR_DB_URL="$PGVECTOR_DB_URL" \
--dry-run=client -o yaml | kubectl apply -f -
echo "Secret '$SECRET_NAME' created/updated in namespace '$NAMESPACE'."