feat: setup terraforms #1

Merged
Noel merged 3 commits from feat/setup_terraforms into main 2026-10-27 13:58:29 +00:00
8 changed files with 23 additions and 30 deletions
Showing only changes of commit c2d356870a - Show all commits

No files matched your search

+1 -1
View File
@@ -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`:
+3 -3
View File
@@ -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"
}
+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" {}
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
}
}
+4 -6
View File
@@ -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".
+3 -2
View File
@@ -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.
+4 -4
View File
@@ -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"
+4 -4
View File
@@ -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" {
+2
View File
@@ -1,4 +1,6 @@
terraform {
required_version = ">= 1.9"
required_providers {
cloudflare = {
source = "cloudflare/cloudflare"