From c2d356870a9bed56f60c6063488eeb3451321aef Mon Sep 17 00:00:00 2001 From: Noel Sabia Date: Tue, 27 Oct 2026 14:53:27 +0100 Subject: [PATCH] refactor(terraform): rename server to cv-control-plane, fix image and server type defaults --- terraform/README.md | 2 +- terraform/dns.tf | 6 +++--- terraform/main.tf | 12 ++---------- terraform/outputs.tf | 10 ++++------ terraform/plan.md | 5 +++-- terraform/terraform.tfvars.example | 8 ++++---- terraform/variables.tf | 8 ++++---- terraform/versions.tf | 2 ++ 8 files changed, 23 insertions(+), 30 deletions(-) diff --git a/terraform/README.md b/terraform/README.md index 8453055..bb23a27 100644 --- a/terraform/README.md +++ b/terraform/README.md @@ -1,6 +1,6 @@ # Terraform -Provisions everything outside the cluster on `server0`. Rebuild is +Provisions everything outside the cluster on `cv-control-plane`. Rebuild is `terraform apply` plus `kubectl apply -k deploy/`. Layout follows `OKF_CV_Website/architecture/terraform.md`: diff --git a/terraform/dns.tf b/terraform/dns.tf index fd90327..9e9f23a 100644 --- a/terraform/dns.tf +++ b/terraform/dns.tf @@ -11,8 +11,8 @@ resource "cloudflare_dns_record" "apex" { zone_id = var.cloudflare_zone_id name = var.domain type = "A" - content = hcloud_server.server0.ipv4_address - ttl = 300 + content = hcloud_server.control_plane.ipv4_address + ttl = 1 proxied = false - comment = "server0, managed by Terraform" + comment = "Remote Server for CV Website" } diff --git a/terraform/main.tf b/terraform/main.tf index 8fce81c..e9bab6e 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -1,10 +1,3 @@ -# Server layer: creates server0 at Hetzner and installs the SSH key at boot. -# Packages, swap, containerd, kubeadm, addons and Caddy follow in later steps -# over SSH; see plan.md. -# -# Terraform does not manage anything inside the cluster beyond the bootstrap -# (namespace cv, quota, addons). Workloads belong to kustomize. - provider "hcloud" {} resource "hcloud_ssh_key" "cv_infra" { @@ -12,8 +5,8 @@ resource "hcloud_ssh_key" "cv_infra" { public_key = file(pathexpand(var.ssh_public_key_path)) } -resource "hcloud_server" "server0" { - name = "server0" +resource "hcloud_server" "control_plane" { + name = "cv-control-plane" server_type = var.server_type image = var.server_image location = var.server_location @@ -22,7 +15,6 @@ resource "hcloud_server" "server0" { public_net { ipv4_enabled = true - # No AAAA record is managed, so do not pay for an unused IPv6. ipv6_enabled = false } } diff --git a/terraform/outputs.tf b/terraform/outputs.tf index ff03d4c..04058ba 100644 --- a/terraform/outputs.tf +++ b/terraform/outputs.tf @@ -1,13 +1,13 @@ # Values other tooling and the operator need after apply. output "server_ip" { - description = "Public IPv4 of server0." - value = hcloud_server.server0.ipv4_address + description = "Public IPv4 of the control plane." + value = hcloud_server.control_plane.ipv4_address } output "ssh_command" { - description = "Ready-to-paste SSH command for server0." - value = "ssh -i ${var.ssh_private_key_path} ${var.ssh_user}@${hcloud_server.server0.ipv4_address}" + description = "Ready-to-paste SSH command for the control plane." + value = "ssh -i ${var.ssh_private_key_path} ${var.ssh_user}@${hcloud_server.control_plane.ipv4_address}" } output "proxy_url" { @@ -15,5 +15,3 @@ output "proxy_url" { value = "https://${var.domain}" } -# Kubeconfig stays on this machine and never enters Git. Add its path here once -# main.tf writes it, e.g. "${path.module}/kubeconfig". diff --git a/terraform/plan.md b/terraform/plan.md index 42e2177..1aa4d86 100644 --- a/terraform/plan.md +++ b/terraform/plan.md @@ -22,7 +22,8 @@ on an empty machine. See `OKF_CV_Website/architecture/terraform.md`. ### 1. Server source — done -`main.tf` creates `server0` as a Hetzner `hcloud_server` (`cx22`, `ubuntu-24.04`) +`main.tf` creates `cv-control-plane` as a Hetzner `hcloud_server` (`cpx32`, +`debian-13`) and registers `~/.ssh/cv_infra.pub` as an `hcloud_ssh_key`, so the key is in `authorized_keys` before the machine boots. `terraform.md` and `README.md` still describe `server_host` as an input; they need updating. @@ -54,7 +55,7 @@ Check: `terraform validate` passes. ### 5. DNS — written `dns.tf` creates `cloudflare_dns_record.apex` from -`hcloud_server.server0.ipv4_address`, so the record can only be created after +`hcloud_server.control_plane.ipv4_address`, so the record can only be created after the server — one `apply` does both, in order. `proxied = false` is required for Caddy's ACME challenge. diff --git a/terraform/terraform.tfvars.example b/terraform/terraform.tfvars.example index 868b4f9..1205372 100644 --- a/terraform/terraform.tfvars.example +++ b/terraform/terraform.tfvars.example @@ -2,8 +2,8 @@ ssh_user = "root" ssh_private_key_path = "~/.ssh/cv_infra" ssh_public_key_path = "~/.ssh/cv_infra.pub" -server_type = "cx22" -server_image = "ubuntu-24.04" +server_type = "cpx32" +server_image = "debian-13" server_location = "nbg1" -domain = "example.dev" -cloudflare_zone_id = "" +domain = "noelsabia.dev" +cloudflare_zone_id = "e8dcd36819c27ef0b77fe4babbe57e21" diff --git a/terraform/variables.tf b/terraform/variables.tf index ab4d426..dd89eb7 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -22,15 +22,15 @@ variable "ssh_public_key_path" { } variable "server_type" { - description = "Hetzner server type. cx22 gives 2 vCPU and 4 GB, the floor for a control plane." + description = "Hetzner server type, e.g. cpx32 (4 vCPU, 8 GB)." type = string - default = "cx22" + default = "cpx32" } variable "server_image" { - description = "Hetzner image for the base system." + description = "Hetzner image for the base system. Hetzner names Debian images by major version only." type = string - default = "ubuntu-24.04" + default = "debian-13" } variable "server_location" { diff --git a/terraform/versions.tf b/terraform/versions.tf index 4c8a011..3ed732b 100644 --- a/terraform/versions.tf +++ b/terraform/versions.tf @@ -1,4 +1,6 @@ terraform { + required_version = ">= 1.9" + required_providers { cloudflare = { source = "cloudflare/cloudflare"