Files
workshop/aula-11/cleanup.sh
T
ArgoCD Setup a0cf1e6cef fix: corrigir tipos de servidor AMD (CPX→CX), autoscaler, stdin e cleanup
- Corrigir tipos Hetzner: CPX não existe, usar CX (Intel shared vCPU)
  - CX23 (2 vCPU, 4GB) equivalente ao CAX11
  - CX33 (4 vCPU, 8GB) equivalente ao CAX21
  - CX43 (8 vCPU, 16GB) equivalente ao CAX31
- Corrigir location no autoscaler para amd64 (nbg1→fsn1)
- Remover gitlab-pool do autoscaler (substituído pelo Gitea)
- Aumentar worker-pool max para 30
- Corrigir Floating IP e Load Balancer hardcoded em nbg1
- Corrigir stdin em read interativo: usar < /dev/tty e read -p
- Corrigir cleanup de namespace: lidar com Terminating e finalizers
- Corrigir CNPG: nome do deployment, secret e endpointURL duplo
- Aulas afetadas: 08, 09, 10, 11, 12, 14, 17
2026-05-09 07:24:26 -03:00

70 lines
2.2 KiB
Bash
Executable File

#!/bin/bash
# =============================================================================
# Aula 11 - Cleanup
# =============================================================================
#
# Remove ArgoCD instalado pelo setup.sh.
# NÃO remove a infraestrutura base (Gitea, 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"
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=120s 2>/dev/null || {
log_warn "Namespace preso em Terminating, forçando remoção..."
kubectl get namespace argocd -o json | \
python3 -c "import sys,json; d=json.load(sys.stdin); d['metadata'].pop('finalizers',None); json.dump(d,sys.stdout)" | \
kubectl replace --raw /api/v1/namespaces/argocd/finalize -f - 2>/dev/null || true
kubectl wait --for=delete namespace argocd --timeout=60s 2>/dev/null || sleep 5
}
# Limpar secrets residuais
log_info "Limpando secrets residuais..."
kubectl delete configmap 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: Gitea, NGINX Ingress e infraestrutura base foram mantidos."
echo "Para remover o Gitea, execute: ../aula-10/cleanup.sh"
echo ""