first commit

This commit is contained in:
2026-03-11 12:16:18 +01:00
commit eb46d77fe7
11 changed files with 412 additions and 0 deletions

122
scripts/deploy.sh Executable file
View File

@@ -0,0 +1,122 @@
#!/bin/bash
# Deploy applications to the Kubernetes cluster
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
KUBECONFIG="${KUBECONFIG:-$HOME/.kube/config-roamflow}"
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
log_info() {
echo -e "${GREEN}[INFO]${NC} $1"
}
log_warn() {
echo -e "${YELLOW}[WARN]${NC} $1"
}
log_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
# Ensure SSH tunnel is running
ensure_tunnel() {
if ! pgrep -f "ssh.*6443.*roamflow-1" > /dev/null; then
log_info "Starting SSH tunnel..."
ssh -f -N -L 6443:127.0.0.1:6443 roamflow-1
sleep 1
fi
}
# Helm chart mappings: app -> (repo_name, repo_url, chart_name)
declare -A HELM_CHARTS=(
["headlamp"]="headlamp|https://headlamp-k8s.github.io/headlamp/|headlamp"
["gitea"]="gitea-charts|https://dl.gitea.com/charts/|gitea"
)
# Add Helm repositories
add_repos() {
log_info "Adding Helm repositories..."
for app in "${!HELM_CHARTS[@]}"; do
IFS='|' read -r repo_name repo_url chart_name <<< "${HELM_CHARTS[$app]}"
helm repo add "$repo_name" "$repo_url" 2>/dev/null || true
done
helm repo update
}
# Deploy a specific app
deploy_app() {
local app=$1
local app_dir="$PROJECT_ROOT/apps/$app"
if [[ ! -d "$app_dir" ]]; then
log_error "App '$app' not found in $PROJECT_ROOT/apps/"
exit 1
fi
log_info "Deploying $app..."
# Apply namespace and other kustomize resources first
if [[ -f "$app_dir/kustomization.yaml" ]]; then
kubectl apply -k "$app_dir" --kubeconfig "$KUBECONFIG"
fi
# Deploy with Helm if values.yaml exists
if [[ -f "$app_dir/values.yaml" ]]; then
if [[ -n "${HELM_CHARTS[$app]}" ]]; then
IFS='|' read -r repo_name repo_url chart_name <<< "${HELM_CHARTS[$app]}"
helm upgrade --install "$app" "$repo_name/$chart_name" \
-f "$app_dir/values.yaml" \
-n "$app" \
--kubeconfig "$KUBECONFIG" \
--create-namespace
else
log_warn "No Helm chart configured for $app, skipping Helm deployment"
fi
fi
log_info "$app deployed successfully!"
}
# List available apps
list_apps() {
echo "Available apps:"
for app_dir in "$PROJECT_ROOT/apps"/*/; do
if [[ -d "$app_dir" ]]; then
app_name=$(basename "$app_dir")
echo " - $app_name"
fi
done
}
# Main
main() {
ensure_tunnel
add_repos
if [[ "$1" == "--all" ]]; then
log_info "Deploying all apps..."
for app_dir in "$PROJECT_ROOT/apps"/*/; do
if [[ -d "$app_dir" ]]; then
app_name=$(basename "$app_dir")
deploy_app "$app_name"
fi
done
elif [[ "$1" == "--list" ]]; then
list_apps
elif [[ -n "$1" ]]; then
deploy_app "$1"
else
echo "Usage: $0 <app-name|--all|--list>"
list_apps
exit 1
fi
}
main "$@"