From 73da8be447444aa7d96bd2d1ccd7c6db364f3831 Mon Sep 17 00:00:00 2001 From: Peter Kurfer Date: Fri, 20 Oct 2023 14:40:45 +0200 Subject: [PATCH] refactor: move to K8s state and move machines to Helsinki --- infrastructure/k8s_flatcar_machines.tf | 14 ++++++-------- infrastructure/lb.tf | 4 ++-- infrastructure/versions.tf | 17 ++++++----------- infrastructure/vms.auto.tfvars | 14 +++----------- 4 files changed, 17 insertions(+), 32 deletions(-) diff --git a/infrastructure/k8s_flatcar_machines.tf b/infrastructure/k8s_flatcar_machines.tf index 52821bd..ff9f694 100644 --- a/infrastructure/k8s_flatcar_machines.tf +++ b/infrastructure/k8s_flatcar_machines.tf @@ -104,13 +104,11 @@ data "ct_config" "machine-ignitions" { } ) snippets = [ - data.template_file.core_user.rendered + templatefile( + "${path.module}/configs/core-user.yaml.tmpl", + { + ssh_keys = jsonencode(concat(var.ssh_keys, [tls_private_key.provisioning.public_key_openssh])) + } + ) ] } - -data "template_file" "core_user" { - template = file("${path.module}/configs/core-user.yaml.tmpl") - vars = { - ssh_keys = jsonencode(concat(var.ssh_keys, [tls_private_key.provisioning.public_key_openssh])) - } -} diff --git a/infrastructure/lb.tf b/infrastructure/lb.tf index 77d7235..ad99f4a 100644 --- a/infrastructure/lb.tf +++ b/infrastructure/lb.tf @@ -18,7 +18,7 @@ resource "hcloud_load_balancer_target" "k8s_lb_target" { } resource "hcloud_managed_certificate" "icb4dc0de_20230613_001" { - name = "icb4dc0de_20230613_001" + name = "icb4dc0de_20230613_001" domain_names = [ "icb4dc0.de", "*.icb4dc0.de", @@ -27,7 +27,7 @@ resource "hcloud_managed_certificate" "icb4dc0de_20230613_001" { "*.prskr.icb4dc0.de", "*.fider.icb4dc0.de", "*.ide.icb4dc0.de", - ] + ] labels = { } } diff --git a/infrastructure/versions.tf b/infrastructure/versions.tf index c314937..0ad69a1 100644 --- a/infrastructure/versions.tf +++ b/infrastructure/versions.tf @@ -2,13 +2,11 @@ terraform { required_version = ">= 0.14" - cloud { - organization = "pkurfer" - - workspaces { - name = "hcloud-infra" - } - } + backend "kubernetes" { + secret_suffix = "state" + config_path = "~/.kube/hetzner.yaml" + namespace = "infrastructure" + } required_providers { hcloud = { @@ -19,10 +17,7 @@ terraform { source = "poseidon/ct" version = "0.11.0" } - template = { - source = "hashicorp/template" - version = "~> 2.2.0" - } + null = { source = "hashicorp/null" version = "~> 3.2.1" diff --git a/infrastructure/vms.auto.tfvars b/infrastructure/vms.auto.tfvars index 5477053..d5f130a 100644 --- a/infrastructure/vms.auto.tfvars +++ b/infrastructure/vms.auto.tfvars @@ -7,14 +7,6 @@ k3os_workers = { location = "hel1" } - "worker2-gen4" = { - backups = false - node_type = "worker" - server_type = "cax21" - private_ip = "172.23.2.21" - location = "fsn1" - } - "w2-cax21-hel1-gen5" = { backups = false node_type = "worker" @@ -23,12 +15,12 @@ k3os_workers = { location = "hel1" } - "worker3-gen4" = { + "w3-cax21-hel1-gen5" = { backups = false node_type = "worker" server_type = "cax21" - private_ip = "172.23.2.22" - location = "fsn1" + private_ip = "172.23.2.25" + location = "hel1" } }