From b33da3eca02c035655e836b9dac5c12d5f1fd28b Mon Sep 17 00:00:00 2001 From: Felix Nehrke Date: Fri, 17 Oct 2025 13:02:59 +0200 Subject: [PATCH] Simplify server and agent definition for kubernetes The definition was split into multiple settings, that made it unnecessary complicated to setup the definition for my kubernetes cluster. This new approach allows for granular definitions of servers and agents and is also simpler to use for me. --- main.tf | 12 ++---------- variables.tf | 49 ++++++++++++++++++------------------------------- 2 files changed, 20 insertions(+), 41 deletions(-) diff --git a/main.tf b/main.tf index fb3b746..87b4f88 100644 --- a/main.tf +++ b/main.tf @@ -9,16 +9,8 @@ module "k8s" { name = "cluster1" ssh_keys = [for o in hcloud_ssh_key.this : o.id] - servers = [for n in range(var.k8s_server_count) : { - type = var.k8s_server_type - location = var.k8s_location - ip_datacenter = var.k8s_ip_datacenter - }] - agents = [{ - type = var.k8s_agent_type - location = var.k8s_location - count = var.k8s_agent_count - }] + servers = var.k8s_servers + agents = var.k8s_agents auto_delete_primary_ips = false kubernetes_exposed_ips = var.kubernetes_allowed_ips ssh_exposed_ips = var.ssh_allowed_ips diff --git a/variables.tf b/variables.tf index 2855fb4..2d09672 100644 --- a/variables.tf +++ b/variables.tf @@ -20,45 +20,32 @@ variable "ssh_keys" { type = map(string) } -# Right now this only supports 1 location, but that's okay for me! -variable "k8s_location" { - type = string +variable "k8s_servers" { + type = list(object({ + type = optional(string, "cax11") + location = string + ip_datacenter = string + })) description = <