diff --git a/terraform/main.tf b/terraform/main.tf index 694ae42..1f2c077 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -63,4 +63,6 @@ module "test_cluster" { client_secret : var.vault_client_secret } vault_allowed_namespaces = ["wahlrecht"] + hcloud_token_enabled = true + hcloud_token = var.hcloud_token } \ No newline at end of file diff --git a/terraform/modules/k8s-cluster/manager-node.tf b/terraform/modules/k8s-cluster/manager-node.tf index 81c601b..bf1cebb 100644 --- a/terraform/modules/k8s-cluster/manager-node.tf +++ b/terraform/modules/k8s-cluster/manager-node.tf @@ -113,6 +113,9 @@ resource "hcloud_server" "manager" { client_id : var.vault_service_principal.client_id client_secret : var.vault_service_principal.client_secret allowed_namespaces : var.vault_allowed_namespaces + hcloud_token_enabled : var.hcloud_token_enabled + hcloud_token : var.hcloud_token + hcloud_namespace : var.hcloud_namespace })) argocd_ha_values : base64encode(file("${path.module}/templates/helm/argocd-values-ha.yaml")) argocd_values : base64encode(file("${path.module}/templates/helm/argocd-values.yaml")) diff --git a/terraform/modules/k8s-cluster/templates/helm/cluster-setup-values.yaml b/terraform/modules/k8s-cluster/templates/helm/cluster-setup-values.yaml index 14e7213..b4317a4 100644 --- a/terraform/modules/k8s-cluster/templates/helm/cluster-setup-values.yaml +++ b/terraform/modules/k8s-cluster/templates/helm/cluster-setup-values.yaml @@ -5,4 +5,8 @@ vault: applicationNamespaces: %{ for namespace in allowed_namespaces ~} - ${namespace} -%{ endfor ~} \ No newline at end of file +%{ endfor ~} +hcloud: + enabled: ${hcloud_token_enabled} + token: ${hcloud_token} + namespace: {$hcloud_namespace} diff --git a/terraform/modules/k8s-cluster/variables.tf b/terraform/modules/k8s-cluster/variables.tf index 605d3f9..f4f7ad7 100644 --- a/terraform/modules/k8s-cluster/variables.tf +++ b/terraform/modules/k8s-cluster/variables.tf @@ -153,4 +153,23 @@ variable "vault_allowed_namespaces" { description = "Namespaces that are allowed to access secrets from the Vault" type = list(string) default = [] +} + +variable "hcloud_token_enabled" { + description = "If true, the hcloud token will be injected into the cluster as a secret" + type = bool + default = true +} + +variable "hcloud_token" { + description = "Contains the hcloud token. If enabled, it must be filled" + type = string + default = "" + sensitive = true +} + +variable "hcloud_namespace" { + description = "Namespace in which the hcloud token will be created" + type = string + default = "hcloud" } \ No newline at end of file