From 3ae15ffdfe5918f85a4ac7e1c011b1aa6bac5594 Mon Sep 17 00:00:00 2001 From: 0xWheatyz Date: Wed, 4 Mar 2026 01:53:20 +0000 Subject: [PATCH] feat(scripts): add GitLab cleanup and redeploy utility MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add script to cleanly remove and redeploy GitLab: redeploy-gitlab.sh: - Deletes existing GitLab deployment and resources - Removes associated PVCs and data - Reapplies GitLab manifests from scratch - Useful for recovering from misconfiguration - Displays new root password after deployment Note: Repository now uses Gitea instead of GitLab, but this script remains for reference or alternative deployments. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- redeploy-gitlab.sh | 103 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100755 redeploy-gitlab.sh diff --git a/redeploy-gitlab.sh b/redeploy-gitlab.sh new file mode 100755 index 0000000..ebbf49b --- /dev/null +++ b/redeploy-gitlab.sh @@ -0,0 +1,103 @@ +#!/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 "=========================================="