From e747d740978250a49dd75b7ae8016f49bdd5c65c Mon Sep 17 00:00:00 2001 From: Vegard Hagen Date: Sun, 23 Mar 2025 19:32:56 +0100 Subject: [PATCH] feat(tofu): better way of supplying apiServer arguments --- tofu/kubernetes/talos/config.tf | 2 +- .../talos/inline-manifests/cilium-install.yaml | 2 +- .../talos/machine-config/control-plane.yaml.tftpl | 8 +------- tofu/kubernetes/talos/variables.tf | 4 ++-- tofu/kubernetes/talos_cluster.auto.tfvars | 10 +++++++++- tofu/kubernetes/variables.tf | 2 +- 6 files changed, 15 insertions(+), 13 deletions(-) diff --git a/tofu/kubernetes/talos/config.tf b/tofu/kubernetes/talos/config.tf index 9082410..05ee8d6 100644 --- a/tofu/kubernetes/talos/config.tf +++ b/tofu/kubernetes/talos/config.tf @@ -36,7 +36,7 @@ data "talos_machine_configuration" "this" { templatefile("${path.module}/machine-config/control-plane.yaml.tftpl", { cilium_values = file("${path.root}/${var.cilium.values_path}") cilium_install = file("${path.root}/${var.cilium.install_manifest_path}") - base_domain = var.cluster.base_domain + api_server = var.cluster.api_server }) : "" ] } diff --git a/tofu/kubernetes/talos/inline-manifests/cilium-install.yaml b/tofu/kubernetes/talos/inline-manifests/cilium-install.yaml index 8be21b8..3db7b48 100644 --- a/tofu/kubernetes/talos/inline-manifests/cilium-install.yaml +++ b/tofu/kubernetes/talos/inline-manifests/cilium-install.yaml @@ -83,4 +83,4 @@ spec: volumes: - name: values configMap: - name: cilium-values \ No newline at end of file + name: cilium-values diff --git a/tofu/kubernetes/talos/machine-config/control-plane.yaml.tftpl b/tofu/kubernetes/talos/machine-config/control-plane.yaml.tftpl index 87306e3..568367b 100644 --- a/tofu/kubernetes/talos/machine-config/control-plane.yaml.tftpl +++ b/tofu/kubernetes/talos/machine-config/control-plane.yaml.tftpl @@ -7,13 +7,7 @@ machine: cluster: allowSchedulingOnControlPlanes: true apiServer: - extraArgs: - oidc-issuer-url: https://authelia.${base_domain} - oidc-client-id: kubectl - oidc-username-claim: preferred_username - oidc-username-prefix: 'authelia:' - oidc-groups-claim: groups - oidc-groups-prefix: 'authelia:' + ${indent(4, api_server)} network: cni: name: none diff --git a/tofu/kubernetes/talos/variables.tf b/tofu/kubernetes/talos/variables.tf index 1d4cf7b..b461a17 100644 --- a/tofu/kubernetes/talos/variables.tf +++ b/tofu/kubernetes/talos/variables.tf @@ -23,7 +23,7 @@ variable "cluster" { talos_machine_config_version = optional(string) proxmox_cluster = string kubernetes_version = string - base_domain = string + api_server = optional(string) }) } @@ -48,6 +48,6 @@ variable "cilium" { description = "Cilium configuration" type = object({ install_manifest_path = string - values_path = string + values_path = string }) } diff --git a/tofu/kubernetes/talos_cluster.auto.tfvars b/tofu/kubernetes/talos_cluster.auto.tfvars index 5c4e844..daf9cb5 100644 --- a/tofu/kubernetes/talos_cluster.auto.tfvars +++ b/tofu/kubernetes/talos_cluster.auto.tfvars @@ -13,7 +13,15 @@ talos_cluster_config = { talos_machine_config_version = "v1.9.2" proxmox_cluster = "homelab" kubernetes_version = "1.32.0" # renovate: github-releases=kubernetes/kubernetes - base_domain = "stonegarden.dev" + api_server = <<-EOT + extraArgs: + oidc-issuer-url: "https://authelia.stonegarden.dev" + oidc-client-id: "kubectl" + oidc-username-claim: "preferred_username" + oidc-username-prefix: "authelia:" + oidc-groups-claim: "groups" + oidc-groups-prefix: "authelia:" + EOT } cilium_config = { diff --git a/tofu/kubernetes/variables.tf b/tofu/kubernetes/variables.tf index 7e1c40d..c72ae75 100644 --- a/tofu/kubernetes/variables.tf +++ b/tofu/kubernetes/variables.tf @@ -39,7 +39,7 @@ variable "talos_cluster_config" { talos_machine_config_version = optional(string) proxmox_cluster = string kubernetes_version = string - base_domain = string + api_server = optional(string) }) }