feat(scripts): add GitLab cleanup and redeploy utility

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 <noreply@anthropic.com>
This commit is contained in:
0xWheatyz 2026-03-04 01:53:20 +00:00
parent f6a3b57bcc
commit 3ae15ffdfe

103
redeploy-gitlab.sh Executable file
View File

@ -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://<node-ip>: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 "=========================================="