#!/usr/bin/env bash set -euo pipefail # Colors for output GREEN='\033[0;32m' BLUE='\033[0;34m' YELLOW='\033[1;33m' RED='\033[0;31m' NC='\033[0m' log_info() { echo -e "${BLUE}[INFO]${NC} $1" } log_success() { echo -e "${GREEN}[SUCCESS]${NC} $1" } log_warning() { echo -e "${YELLOW}[WARNING]${NC} $1" } log_error() { echo -e "${RED}[ERROR]${NC} $1" } echo "==========================================" echo "GitLab Cleanup and Redeployment" echo "==========================================" echo "" # Check if storage class exists log_info "Checking for storage class..." if ! kubectl get storageclass local-path &> /dev/null; then log_error "Storage class 'local-path' not found!" log_info "Please run: ./install-local-path-storage.sh first" exit 1 fi log_success "Storage class 'local-path' found" echo "" # Delete existing GitLab deployment log_warning "Cleaning up existing GitLab deployment..." if kubectl get namespace gitlab &> /dev/null; then log_info "Deleting GitLab deployment..." kubectl delete -k testing1/first-cluster/apps/gitlab/ --ignore-not-found=true || true log_info "Waiting for pods to terminate..." kubectl wait --for=delete pod --all -n gitlab --timeout=120s 2>/dev/null || true log_info "Deleting PVCs (this will delete all data!)..." kubectl delete pvc --all -n gitlab --ignore-not-found=true || true log_info "Waiting for PVCs to be deleted..." sleep 5 log_success "Cleanup complete" else log_info "GitLab namespace doesn't exist - nothing to clean up" fi echo "" # Deploy GitLab log_info "Deploying GitLab with local-path storage..." kubectl apply -k testing1/first-cluster/apps/gitlab/ echo "" log_info "Waiting for PVCs to be bound..." sleep 5 # Check PVC status kubectl get pvc -n gitlab echo "" log_info "Waiting for GitLab pod to be created..." sleep 10 # Show pod status kubectl get pods -n gitlab echo "" log_success "GitLab deployment initiated!" echo "" log_info "Monitor deployment progress with:" echo " kubectl get pods -n gitlab -w" echo "" log_info "GitLab will take 5-10 minutes to fully start up." echo "" log_info "Once running, access GitLab at:" echo " http://:30080" echo "" log_info "Get the initial root password with:" echo " kubectl exec -n gitlab deployment/gitlab -- grep 'Password:' /etc/gitlab/initial_root_password" echo "" echo "=========================================="