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:
+1
-1
@@ -47,7 +47,7 @@ if [ -f "kubeconfig" ]; then
|
||||
# Detectar arch dos nodes para filtrar instance type correto
|
||||
NODE_ARCH=$(kubectl get nodes -o jsonpath='{.items[0].metadata.labels.kubernetes\.io/arch}' 2>/dev/null || echo "arm64")
|
||||
if [[ "$NODE_ARCH" == "amd64" ]]; then
|
||||
INSTANCE_PATTERN="cpx"
|
||||
INSTANCE_PATTERN="cx"
|
||||
else
|
||||
INSTANCE_PATTERN="cax"
|
||||
fi
|
||||
|
||||
@@ -128,10 +128,7 @@ spec:
|
||||
# POOLS DE NODES:
|
||||
#
|
||||
# worker-pool: Workloads gerais (CAX21 = 4 vCPU, 8GB)
|
||||
- --nodes=1:3:CAX21:nbg1:worker-pool
|
||||
#
|
||||
# gitlab-pool: Gitea e serviços pesados (CAX21)
|
||||
- --nodes=1:2:CAX21:nbg1:gitlab-pool
|
||||
- --nodes=1:30:CAX21:nbg1:worker-pool
|
||||
#
|
||||
# build-pool: Builds Docker (CAX31 = 8 vCPU, 16GB)
|
||||
# Escala 0-1 sob demanda, taint "dedicated=builds:NoSchedule"
|
||||
|
||||
+4
-4
@@ -38,14 +38,14 @@ locals {
|
||||
# Endpoint: LoadBalancer IP if enabled, otherwise Floating IP
|
||||
cluster_endpoint_ip = var.enable_loadbalancer ? hcloud_load_balancer.cluster[0].ipv4 : hcloud_floating_ip.control_plane[0].ip_address
|
||||
|
||||
# Arquitetura: mapeia arm64→CAX (Nuremberg) ou amd64→CPX (Frankfurt)
|
||||
# Arquitetura: mapeia arm64→CAX (Nuremberg) ou amd64→CX (Frankfurt)
|
||||
arch_config = {
|
||||
arm64 = {
|
||||
server_type_cp = "cax11"
|
||||
location = "nbg1"
|
||||
}
|
||||
amd64 = {
|
||||
server_type_cp = "cpx21"
|
||||
server_type_cp = "cx23"
|
||||
location = "fsn1"
|
||||
}
|
||||
}
|
||||
@@ -247,7 +247,7 @@ resource "hcloud_floating_ip" "control_plane" {
|
||||
count = var.enable_loadbalancer ? 0 : 1
|
||||
type = "ipv4"
|
||||
name = "${local.cluster_name}-cp-ip"
|
||||
home_location = "nbg1"
|
||||
home_location = local.selected_arch.location
|
||||
labels = local.common_labels
|
||||
}
|
||||
|
||||
@@ -265,7 +265,7 @@ resource "hcloud_load_balancer" "cluster" {
|
||||
count = var.enable_loadbalancer ? 1 : 0
|
||||
name = "${local.cluster_name}-lb"
|
||||
load_balancer_type = "lb11"
|
||||
location = "nbg1"
|
||||
location = local.selected_arch.location
|
||||
labels = local.common_labels
|
||||
}
|
||||
|
||||
|
||||
+6
-6
@@ -240,13 +240,13 @@ if [ "$SKIP_CREDENTIALS" != "true" ]; then
|
||||
echo "6. Arquitetura dos nodes"
|
||||
echo ""
|
||||
echo " arm64 (CAX) - Ampere Altra, melhor custo/benefício"
|
||||
echo " amd64 (CPX) - AMD EPYC, mais disponível"
|
||||
echo " amd64 (CX) - Intel, mais disponível"
|
||||
echo ""
|
||||
read -p " Arquitetura? (arm64/amd64) [arm64]: " arch_input
|
||||
ARCH="${arch_input:-arm64}"
|
||||
|
||||
if [[ "$ARCH" == "amd64" ]]; then
|
||||
log_success "AMD64 selecionado (CPX em fsn1)"
|
||||
log_success "AMD64 selecionado (CX em fsn1)"
|
||||
else
|
||||
log_success "ARM64 selecionado (CAX em nbg1)"
|
||||
ARCH="arm64"
|
||||
@@ -317,8 +317,8 @@ ENABLE_LB_CONFIG=$(grep 'enable_loadbalancer' terraform.tfvars 2>/dev/null | gre
|
||||
# Custos estimados baseado na arquitetura selecionada
|
||||
ARCH_CONFIG=$(grep 'arch' terraform.tfvars 2>/dev/null | grep -o 'arm64\|amd64' || echo "arm64")
|
||||
if [[ "$ARCH_CONFIG" == "amd64" ]]; then
|
||||
NODE_TYPE="CPX21"
|
||||
NODE_COST="\$6.99"
|
||||
NODE_TYPE="CX23"
|
||||
NODE_COST="\$4.99"
|
||||
else
|
||||
NODE_TYPE="CAX11"
|
||||
NODE_COST="\$4.59"
|
||||
@@ -575,13 +575,13 @@ log_info "Aplicando manifesto do cluster-autoscaler..."
|
||||
# Ajustar server_types do autoscaler conforme arquitetura
|
||||
if [[ "$ARCH" == "amd64" ]]; then
|
||||
AUTOSCALER_FILE="${SCRIPT_DIR}/cluster-autoscaler.yaml"
|
||||
# CPX equivalentes: CAX21→CPX31, CAX31→CPX41, CAX11→CPX21
|
||||
# CX equivalentes: CAX21→CX33, CAX31→CX43, CAX11→CX23
|
||||
cat "$AUTOSCALER_FILE" | \
|
||||
sed "s|\${TALOS_IMAGE_ID}|$TALOS_IMAGE_ID|g" | \
|
||||
sed "s|\${NETWORK_NAME}|$CLUSTER_NAME-network|g" | \
|
||||
sed "s|\${FIREWALL_NAME}|$CLUSTER_NAME-firewall|g" | \
|
||||
sed "s|\${SSH_KEY_NAME}|$SSH_KEY_NAME|g" | \
|
||||
sed -e 's/CAX21/CPX31/g' -e 's/CAX31/CPX41/g' -e 's/CAX11/CPX21/g' | \
|
||||
sed -e 's/CAX21/CX33/g' -e 's/CAX31/CX43/g' -e 's/CAX11/CX23/g' -e 's/:nbg1:/:fsn1:/g' | \
|
||||
kubectl apply -f -
|
||||
else
|
||||
cat cluster-autoscaler.yaml | \
|
||||
|
||||
@@ -24,9 +24,9 @@ talos_image_id = 123456789
|
||||
# Ambiente (prod, staging, dev)
|
||||
environment = "workshop"
|
||||
|
||||
# Arquitetura dos nodes: arm64 (CAX) ou amd64 (CPX)
|
||||
# Arquitetura dos nodes: arm64 (CAX) ou amd64 (CX)
|
||||
# arm64 = CAX11/21/31 em Nuremberg (nbg1) - melhor custo
|
||||
# amd64 = CPX21/31/41 em Frankfurt (fsn1) - mais disponível
|
||||
# amd64 = CX23/33/43 em Frankfurt (fsn1) - mais disponível
|
||||
# arch = "arm64"
|
||||
|
||||
# Versão do Talos OS (opcional - default: v1.11.2)
|
||||
|
||||
@@ -74,7 +74,7 @@ variable "talos_version" {
|
||||
|
||||
variable "arch" {
|
||||
type = string
|
||||
description = "Arquitetura dos nodes: arm64 (CAX - Ampere Altra, melhor custo) ou amd64 (CPX - AMD EPYC, mais disponível)"
|
||||
description = "Arquitetura dos nodes: arm64 (CAX - Ampere Altra, melhor custo) ou amd64 (CX - Intel, mais disponível)"
|
||||
default = "arm64"
|
||||
|
||||
validation {
|
||||
|
||||
Reference in New Issue
Block a user