Files
workshop/aula-11/cleanup.sh
Allyson de Paula 8e743f6e69 aula-11: ArgoCD + GitLab Runner para GitOps CI/CD
- ArgoCD via Helm com recursos mínimos (~1Gi)
- GitLab Runner com executor Kubernetes
- Exemplo node-bugado com Dockerfile e .gitlab-ci.yml
- Manifests K8s para repositório GitOps
- README.md da aula-03 (liveness + readiness probes)
2025-12-31 21:19:40 -03:00

73 lines
2.1 KiB
Bash
Executable File

#!/bin/bash
# =============================================================================
# Aula 11 - Cleanup
# =============================================================================
#
# Remove ArgoCD e GitLab Runner instalados pelo setup.sh.
# NÃO remove a infraestrutura base (GitLab, NGINX Ingress, etc).
#
# =============================================================================
set -e
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
log_info() { echo -e "${BLUE}[INFO]${NC} $1"; }
log_success() { echo -e "${GREEN}[OK]${NC} $1"; }
log_warn() { echo -e "${YELLOW}[WARN]${NC} $1"; }
log_error() { echo -e "${RED}[ERROR]${NC} $1"; }
echo ""
echo "=========================================="
echo " Removendo ArgoCD e GitLab Runner"
echo "=========================================="
echo ""
# Remover ArgoCD Applications primeiro
log_info "Removendo ArgoCD Applications..."
kubectl delete applications --all -n argocd 2>/dev/null || true
# Remover ArgoCD
log_info "Removendo ArgoCD..."
if helm status argocd -n argocd &> /dev/null; then
helm uninstall argocd -n argocd --wait
log_success "ArgoCD removido"
else
log_warn "ArgoCD não estava instalado"
fi
# Remover namespace argocd
log_info "Removendo namespace argocd..."
kubectl delete namespace argocd --timeout=60s 2>/dev/null || true
# Remover GitLab Runner
log_info "Removendo GitLab Runner..."
if helm status gitlab-runner -n gitlab &> /dev/null; then
helm uninstall gitlab-runner -n gitlab --wait
log_success "GitLab Runner removido"
else
log_warn "GitLab Runner não estava instalado"
fi
# Limpar secrets residuais
log_info "Limpando secrets residuais..."
kubectl delete secret argocd-ssh-known-hosts-cm -n argocd 2>/dev/null || true
# Remover arquivo .env local
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
if [[ -f "${SCRIPT_DIR}/.env" ]]; then
rm "${SCRIPT_DIR}/.env"
log_info "Arquivo .env removido"
fi
echo ""
log_success "Cleanup concluído!"
echo ""
echo "Nota: GitLab, NGINX Ingress e infraestrutura base foram mantidos."
echo "Para remover o GitLab, execute: ../aula-10/cleanup.sh"
echo ""