refactor(terraform): rename server to cv-control-plane, fix image and server type defaults

This commit is contained in:
Noel Sabia committed 2026-10-27 14:53:27 +01:00
1 parent 8e0c1a8796
commit c2d356870a
8 files changed
+23 -30

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
# Terraform # 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/`. `terraform apply` plus `kubectl apply -k deploy/`.
Layout follows `OKF_CV_Website/architecture/terraform.md`: Layout follows `OKF_CV_Website/architecture/terraform.md`:
+3 -3
View File
@@ -11,8 +11,8 @@ resource "cloudflare_dns_record" "apex" {
zone_id = var.cloudflare_zone_id zone_id = var.cloudflare_zone_id
name = var.domain name = var.domain
type = "A" type = "A"
content = hcloud_server.server0.ipv4_address content = hcloud_server.control_plane.ipv4_address
ttl = 300 ttl = 1
proxied = false proxied = false
comment = "server0, managed by Terraform" comment = "Remote Server for CV Website"
} }
+2 -10
View File
@@ -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" {} provider "hcloud" {}
resource "hcloud_ssh_key" "cv_infra" { 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)) public_key = file(pathexpand(var.ssh_public_key_path))
} }
resource "hcloud_server" "server0" { resource "hcloud_server" "control_plane" {
name = "server0" name = "cv-control-plane"
server_type = var.server_type server_type = var.server_type
image = var.server_image image = var.server_image
location = var.server_location location = var.server_location
@@ -22,7 +15,6 @@ resource "hcloud_server" "server0" {
public_net { public_net {
ipv4_enabled = true ipv4_enabled = true
# No AAAA record is managed, so do not pay for an unused IPv6.
ipv6_enabled = false ipv6_enabled = false
} }
} }
+4 -6
View File
@@ -1,13 +1,13 @@
# Values other tooling and the operator need after apply. # Values other tooling and the operator need after apply.
output "server_ip" { output "server_ip" {
description = "Public IPv4 of server0." description = "Public IPv4 of the control plane."
value = hcloud_server.server0.ipv4_address value = hcloud_server.control_plane.ipv4_address
} }
output "ssh_command" { output "ssh_command" {
description = "Ready-to-paste SSH command for server0." description = "Ready-to-paste SSH command for the control plane."
value = "ssh -i ${var.ssh_private_key_path} ${var.ssh_user}@${hcloud_server.server0.ipv4_address}" value = "ssh -i ${var.ssh_private_key_path} ${var.ssh_user}@${hcloud_server.control_plane.ipv4_address}"
} }
output "proxy_url" { output "proxy_url" {
@@ -15,5 +15,3 @@ output "proxy_url" {
value = "https://${var.domain}" 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".
+3 -2
View File
@@ -22,7 +22,8 @@ on an empty machine. See `OKF_CV_Website/architecture/terraform.md`.
### 1. Server source — done ### 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 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 `authorized_keys` before the machine boots. `terraform.md` and `README.md` still
describe `server_host` as an input; they need updating. describe `server_host` as an input; they need updating.
@@ -54,7 +55,7 @@ Check: `terraform validate` passes.
### 5. DNS — written ### 5. DNS — written
`dns.tf` creates `cloudflare_dns_record.apex` from `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 the server — one `apply` does both, in order. `proxied = false` is required for
Caddy's ACME challenge. Caddy's ACME challenge.
+4 -4
View File
@@ -2,8 +2,8 @@
ssh_user = "root" ssh_user = "root"
ssh_private_key_path = "~/.ssh/cv_infra" ssh_private_key_path = "~/.ssh/cv_infra"
ssh_public_key_path = "~/.ssh/cv_infra.pub" ssh_public_key_path = "~/.ssh/cv_infra.pub"
server_type = "cx22" server_type = "cpx32"
server_image = "ubuntu-24.04" server_image = "debian-13"
server_location = "nbg1" server_location = "nbg1"
domain = "example.dev" domain = "noelsabia.dev"
cloudflare_zone_id = "" cloudflare_zone_id = "e8dcd36819c27ef0b77fe4babbe57e21"
+4 -4
View File
@@ -22,15 +22,15 @@ variable "ssh_public_key_path" {
} }
variable "server_type" { 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 type = string
default = "cx22" default = "cpx32"
} }
variable "server_image" { 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 type = string
default = "ubuntu-24.04" default = "debian-13"
} }
variable "server_location" { variable "server_location" {
+2
View File
@@ -1,4 +1,6 @@
terraform { terraform {
required_version = ">= 1.9"
required_providers { required_providers {
cloudflare = { cloudflare = {
source = "cloudflare/cloudflare" source = "cloudflare/cloudflare"