rancher / terraform-provider-rancher2

Terraform Rancher2 provider
https://www.terraform.io/docs/providers/rancher2/
Mozilla Public License 2.0
263 stars 228 forks source link

[BUG] "write-kubeconfig" and "write-kubeconfig-mode" ignored when used in machine_global_config #1384

Open upics opened 3 months ago

upics commented 3 months ago

Rancher Server Setup

Information about the Cluster

Provider Information

Describe the bug

When using write-kubeconfig-mode to set 644 chmod to k3s.yaml file, via machine_global_config, seems that the parameter is ignored. Same for write-kubeconfig. Instead when using other parameters (https://docs.k3s.io/cli/server), they are correctly considered.

To Reproduce

resource "rancher2_cluster_v2" "cluster" {
    name = var.rancher.cluster.name
    kubernetes_version = var.rancher.cluster.k3s_version

    rke_config {
      machine_selector_config {
        machine_label_selector {
          match_labels = {
            "rke.cattle.io/worker-role" = "true",
          }
        }
        config = <<EOF
        system-default-registry: 
        EOF
      } 

      machine_global_config = yamlencode({
        system-default-registry = local.registry.url
        flannel-backend = "none"
        disable-network-policy = true
        cluster-init = true
        disable = "traefik"
        write-kubeconfig-mode = "0644"
        write-kubeconfig = "/tmp/kubeconfig_output"
        cluster-cidr = "192.168.201.0/24"
      })

      registries {
        configs {
          hostname = element(split("/", local.registry.url), 0)
          auth_config_secret_name = rancher2_secret_v2.auth-private-registry.name
          ca_bundle = join("",[one(values(tls_private_key.registry_cert_private_key)).private_key_pem, one(values(tls_locally_signed_cert.registry_cert)).cert_pem, one(values(tls_self_signed_cert.registry_ca_cert)).cert_pem])
        }
      }
    }
}

Actual Result

image

Expected Result

image