49 lines
1.3 KiB
Bash
Executable File
49 lines
1.3 KiB
Bash
Executable File
#!/bin/bash
|
|
# Setup Gitea Admin Secret
|
|
#
|
|
# This script creates the Kubernetes secret required for Gitea admin credentials.
|
|
# Run this BEFORE installing Gitea with Helm.
|
|
#
|
|
# Usage:
|
|
# ./setup-admin-secret.sh [password]
|
|
#
|
|
# If password is not provided, a random one will be generated.
|
|
|
|
set -e
|
|
|
|
KUBECTL="kubectl"
|
|
NAMESPACE="gitea"
|
|
|
|
# Check if running in microk8s
|
|
if command -v microk8s &> /dev/null; then
|
|
KUBECTL="microk8s kubectl"
|
|
fi
|
|
|
|
# Get or generate password
|
|
if [ -n "$1" ]; then
|
|
ADMIN_PASSWORD="$1"
|
|
else
|
|
ADMIN_PASSWORD=$(openssl rand -base64 24 | tr -d '/+=' | head -c 20)
|
|
echo "Generated admin password: $ADMIN_PASSWORD"
|
|
fi
|
|
|
|
# Create namespace if it doesn't exist
|
|
$KUBECTL create namespace "$NAMESPACE" --dry-run=client -o yaml | $KUBECTL apply -f -
|
|
|
|
# Create the secret
|
|
$KUBECTL create secret generic gitea-admin-secret \
|
|
--namespace "$NAMESPACE" \
|
|
--from-literal=username=bakery-admin \
|
|
--from-literal=password="$ADMIN_PASSWORD" \
|
|
--dry-run=client -o yaml | $KUBECTL apply -f -
|
|
|
|
echo ""
|
|
echo "Gitea admin secret created successfully!"
|
|
echo ""
|
|
echo "Admin credentials:"
|
|
echo " Username: bakery-admin"
|
|
echo " Password: $ADMIN_PASSWORD"
|
|
echo ""
|
|
echo "Now install Gitea with:"
|
|
echo " helm install gitea gitea/gitea -n gitea -f infrastructure/cicd/gitea/values.yaml"
|