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
This commit is contained in:
ArgoCD Setup
2026-05-09 07:24:26 -03:00
parent 3d042a29ae
commit a0cf1e6cef
18 changed files with 153 additions and 92 deletions
+16 -10
View File
@@ -135,26 +135,22 @@ collect_config() {
if [[ -z "$S3_ENDPOINT" ]]; then
S3_ENDPOINT="nbg1.your-objectstorage.com"
fi
echo -ne "Endpoint (${GREEN}${S3_ENDPOINT}${NC}): "
read -r input
read -r -p "Endpoint (${GREEN}${S3_ENDPOINT}${NC}): " input < /dev/tty
[[ -n "$input" ]] && S3_ENDPOINT="$input"
if [[ -z "$S3_BUCKET" ]]; then
S3_BUCKET="cnpg-backups"
fi
echo -ne "Bucket name (${GREEN}${S3_BUCKET}${NC}): "
read -r input
read -r -p "Bucket name (${GREEN}${S3_BUCKET}${NC}): " input < /dev/tty
[[ -n "$input" ]] && S3_BUCKET="$input"
echo -ne "Access Key ID: "
read -r S3_ACCESS_KEY
read -r -p "Access Key ID: " S3_ACCESS_KEY < /dev/tty
if [[ -z "$S3_ACCESS_KEY" ]]; then
log_error "Access Key é obrigatória"
exit 1
fi
echo -ne "Secret Access Key: "
read -rs S3_SECRET_KEY
read -rs -p "Secret Access Key: " S3_SECRET_KEY < /dev/tty
echo ""
if [[ -z "$S3_SECRET_KEY" ]]; then
log_error "Secret Key é obrigatória"
@@ -191,7 +187,7 @@ install_cnpg_operator() {
log_success "CNPG operator instalado"
log_info "Aguardando operator ficar ready..."
kubectl wait --for=condition=available deployment/cnpg-controller-manager -n cnpg-system --timeout=120s
kubectl wait --for=condition=available deployment/cnpg-cloudnative-pg -n cnpg-system --timeout=120s
log_success "CNPG operator pronto"
}
@@ -205,6 +201,16 @@ setup_namespace_and_secrets() {
echo -e "${CYAN} Criando namespace e secrets${NC}"
echo -e "${CYAN}═══════════════════════════════════════════════════════════${NC}"
if kubectl get namespace cnpg &>/dev/null; then
NS_PHASE=$(kubectl get namespace cnpg -o jsonpath='{.status.phase}' 2>/dev/null)
if [[ "$NS_PHASE" == "Terminating" ]]; then
log_info "Namespace cnpg em Terminating, forçando remoção..."
kubectl get namespace cnpg -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/cnpg/finalize -f - 2>/dev/null || true
kubectl wait --for=delete namespace cnpg --timeout=60s 2>/dev/null || sleep 5
fi
fi
kubectl create namespace cnpg --dry-run=client -o yaml | kubectl apply -f -
log_info "Criando secret de credenciais S3..."
@@ -228,7 +234,7 @@ create_cluster() {
log_info "Gerando cluster.yaml com suas configurações..."
sed -e "s|CHANGE_BUCKET_NAME|${S3_BUCKET}|g" \
-e "s|CHANGE_ENDPOINT|https://${S3_ENDPOINT}|g" \
-e "s|CHANGE_ENDPOINT|${S3_ENDPOINT}|g" \
"${SCRIPT_DIR}/cnpg/cluster.yaml" | kubectl apply -f -
log_success "Cluster aplicado"