diff --git a/init.tf b/init.tf index 2f72ce75..a7efa847 100644 --- a/init.tf +++ b/init.tf @@ -252,6 +252,17 @@ resource "null_resource" "kustomization" { destination = "/var/post_install/longhorn.yaml" } + # Upload the csi-driver-smb config + provisioner "file" { + content = templatefile( + "${path.module}/templates/hcloud-csi.yaml.tpl", + { + version = local.csi_version + values = indent(4, trimspace(var.hetzner_csi_values)) + }) + destination = "/var/post_install/hcloud-csi.yaml" + } + # Upload the csi-driver-smb config provisioner "file" { content = templatefile( @@ -305,7 +316,6 @@ resource "null_resource" "kustomization" { "set -ex", "kubectl -n kube-system create secret generic hcloud --from-literal=token=${var.hcloud_token} --from-literal=network=${data.hcloud_network.k3s.name} --dry-run=client -o yaml | kubectl apply -f -", "kubectl -n kube-system create secret generic hcloud-csi --from-literal=token=${var.hcloud_token} --dry-run=client -o yaml | kubectl apply -f -", - local.csi_version != null ? "curl https://raw.githubusercontent.com/hetznercloud/csi-driver/${coalesce(local.csi_version, "v2.4.0")}/deploy/kubernetes/hcloud-csi.yml -o /var/post_install/hcloud-csi.yml" : "echo 'Skipping hetzner csi.'" ] } diff --git a/locals.tf b/locals.tf index baf8801a..5a56e5fc 100644 --- a/locals.tf +++ b/locals.tf @@ -78,7 +78,7 @@ locals { "https://github.com/kubereboot/kured/releases/download/${local.kured_version}/kured-${local.kured_version}-dockerhub.yaml", "https://raw.githubusercontent.com/rancher/system-upgrade-controller/9e7e45c1bdd528093da36be1f1f32472469005e6/manifests/system-upgrade-controller.yaml", ], - var.disable_hetzner_csi ? [] : ["hcloud-csi.yml"], + var.disable_hetzner_csi ? [] : ["hcloud-csi.yaml"], lookup(local.ingress_controller_install_resources, var.ingress_controller, []), lookup(local.cni_install_resources, var.cni_plugin, []), var.enable_longhorn ? ["longhorn.yaml"] : [], diff --git a/templates/hcloud-csi.yaml.tpl b/templates/hcloud-csi.yaml.tpl new file mode 100644 index 00000000..275c7e31 --- /dev/null +++ b/templates/hcloud-csi.yaml.tpl @@ -0,0 +1,14 @@ +--- +apiVersion: helm.cattle.io/v1 +kind: HelmChart +metadata: + name: hcloud-csi + namespace: kube-system +spec: + chart: hcloud-csi + repo: https://charts.hetzner.cloud + version: "${version}" + targetNamespace: kube-system + bootstrap: true + valuesContent: |- + ${values} \ No newline at end of file diff --git a/variables.tf b/variables.tf index 1e77110c..f1653db9 100644 --- a/variables.tf +++ b/variables.tf @@ -357,6 +357,13 @@ variable "hetzner_csi_version" { description = "Version of Container Storage Interface driver for Hetzner Cloud." } +variable "hetzner_csi_values" { + type = string + default = "" + description = "Additional helm values file to pass to hetzner csi as 'valuesContent' at the HelmChart." +} + + variable "restrict_outbound_traffic" { type = bool default = true