72ffe47528
- Variável `arch` no Terraform: arm64 (CAX11 em nbg1) ou amd64 (CPX21 em fsn1) - locals map traduz arch → server_type + location - setup.sh pergunta arquitetura interativamente (default: arm64) - Detecta OpenTofu ou Terraform automaticamente (preferência tofu) - Autoscaler: sed troca CAX→CPX nos server_types quando amd64 - tfvars gerado inclui arch selecionado
95 lines
2.7 KiB
Terraform
95 lines
2.7 KiB
Terraform
############################################################
|
|
# Variables for Hetzner Talos Kubernetes Cluster
|
|
############################################################
|
|
|
|
# ==========================================================
|
|
# AUTENTICAÇÃO
|
|
# ==========================================================
|
|
|
|
variable "hcloud_token" {
|
|
type = string
|
|
description = "Hetzner Cloud API token"
|
|
sensitive = true
|
|
}
|
|
|
|
# ==========================================================
|
|
# CONFIGURAÇÃO DO CLUSTER
|
|
# ==========================================================
|
|
|
|
variable "enable_ha" {
|
|
type = bool
|
|
description = "Enable HA mode with 3 control plane nodes"
|
|
default = true
|
|
}
|
|
|
|
variable "enable_loadbalancer" {
|
|
type = bool
|
|
description = "Enable Hetzner Load Balancer for HA access to control plane and ingress"
|
|
default = true
|
|
}
|
|
|
|
variable "environment" {
|
|
type = string
|
|
description = "Environment name (prod, staging, dev)"
|
|
default = "prod"
|
|
|
|
validation {
|
|
condition = contains(["prod", "staging", "dev"], var.environment)
|
|
error_message = "Environment deve ser: prod, staging ou dev."
|
|
}
|
|
}
|
|
|
|
# ==========================================================
|
|
# SSH
|
|
# ==========================================================
|
|
|
|
variable "ssh_public_key" {
|
|
type = string
|
|
description = "Public SSH key for emergency access to nodes"
|
|
}
|
|
|
|
# ==========================================================
|
|
# TALOS
|
|
# ==========================================================
|
|
|
|
variable "talos_image_id" {
|
|
type = number
|
|
description = "ID da imagem Talos customizada na Hetzner (criada na aula-07). Obtenha com: hcloud image list --type snapshot"
|
|
}
|
|
|
|
variable "talos_version" {
|
|
type = string
|
|
description = "Talos version to use"
|
|
default = "v1.11.2"
|
|
|
|
validation {
|
|
condition = can(regex("^v[0-9]+\\.[0-9]+\\.[0-9]+$", var.talos_version))
|
|
error_message = "talos_version deve seguir o formato semântico: v1.2.3"
|
|
}
|
|
}
|
|
|
|
# ==========================================================
|
|
# ARQUITETURA
|
|
# ==========================================================
|
|
|
|
variable "arch" {
|
|
type = string
|
|
description = "Arquitetura dos nodes: arm64 (CAX - Ampere Altra, melhor custo) ou amd64 (CPX - AMD EPYC, mais disponível)"
|
|
default = "arm64"
|
|
|
|
validation {
|
|
condition = contains(["arm64", "amd64"], var.arch)
|
|
error_message = "arch deve ser arm64 ou amd64."
|
|
}
|
|
}
|
|
|
|
# ==========================================================
|
|
# LABELS CUSTOMIZADAS
|
|
# ==========================================================
|
|
|
|
variable "custom_labels" {
|
|
type = map(string)
|
|
description = "Custom labels to add to all resources"
|
|
default = {}
|
|
}
|