diff --git a/agents.tf b/agents.tf index 1e052e3..7d04709 100644 --- a/agents.tf +++ b/agents.tf @@ -44,19 +44,15 @@ resource "null_resource" "agents" { # Generating k3s agent config file provisioner "file" { - content = yamlencode(merge({ + content = yamlencode({ node-name = module.agents[each.key].name server = "https://${module.control_planes[0].private_ipv4_address}:6443" token = random_password.k3s_token.result - kubelet-arg = "cloud-provider=external" + kubelet-arg = ["cloud-provider=external", "volume-plugin-dir=/var/lib/kubelet/volumeplugins"] flannel-iface = "eth1" node-ip = module.agents[each.key].private_ipv4_address node-label = var.automatically_upgrade_k3s ? ["k3s_upgrade=true"] : [] - }, - var.cni_plugin == "calico" ? { - flannel-backend = "none" - kube-controller-manager-arg = "flex-volume-plugin-dir=/var/lib/kubelet/volumeplugins" - } : {})) + }) destination = "/tmp/config.yaml" } diff --git a/control_planes.tf b/control_planes.tf index 41a014e..46b846d 100644 --- a/control_planes.tf +++ b/control_planes.tf @@ -44,22 +44,22 @@ resource "null_resource" "control_planes" { # Generating k3s server config file provisioner "file" { content = yamlencode(merge({ - node-name = module.control_planes[count.index].name - server = "https://${element(module.control_planes.*.private_ipv4_address, count.index > 0 ? 0 : 1)}:6443" - token = random_password.k3s_token.result - disable-cloud-controller = true - disable = local.disable_extras - flannel-iface = "eth1" - kubelet-arg = "cloud-provider=external" - node-ip = module.control_planes[count.index].private_ipv4_address - advertise-address = module.control_planes[count.index].private_ipv4_address - node-taint = var.allow_scheduling_on_control_plane ? [] : ["node-role.kubernetes.io/master:NoSchedule"] - node-label = var.automatically_upgrade_k3s ? ["k3s_upgrade=true"] : [] - disable-network-policy = var.cni_plugin == "calico" ? true : var.disable_network_policy + node-name = module.control_planes[count.index].name + server = "https://${element(module.control_planes.*.private_ipv4_address, count.index > 0 ? 0 : 1)}:6443" + token = random_password.k3s_token.result + disable-cloud-controller = true + disable = local.disable_extras + flannel-iface = "eth1" + kubelet-arg = ["cloud-provider=external", "volume-plugin-dir=/var/lib/kubelet/volumeplugins"] + kube-controller-manager-arg = "flex-volume-plugin-dir=/var/lib/kubelet/volumeplugins" + node-ip = module.control_planes[count.index].private_ipv4_address + advertise-address = module.control_planes[count.index].private_ipv4_address + node-taint = var.allow_scheduling_on_control_plane ? [] : ["node-role.kubernetes.io/master:NoSchedule"] + node-label = var.automatically_upgrade_k3s ? ["k3s_upgrade=true"] : [] + disable-network-policy = var.cni_plugin == "calico" ? true : var.disable_network_policy }, var.cni_plugin == "calico" ? { - flannel-backend = "none" - kube-controller-manager-arg = "flex-volume-plugin-dir=/var/lib/kubelet/volumeplugins" + flannel-backend = "none" } : {})) destination = "/tmp/config.yaml" } diff --git a/init.tf b/init.tf index 5e4f264..dfd52f3 100644 --- a/init.tf +++ b/init.tf @@ -9,22 +9,22 @@ resource "null_resource" "first_control_plane" { # Generating k3s master config file provisioner "file" { content = yamlencode(merge({ - node-name = module.control_planes[0].name - token = random_password.k3s_token.result - cluster-init = true - disable-cloud-controller = true - disable = local.disable_extras - flannel-iface = "eth1" - kubelet-arg = "cloud-provider=external" - node-ip = module.control_planes[0].private_ipv4_address - advertise-address = module.control_planes[0].private_ipv4_address - node-taint = var.allow_scheduling_on_control_plane ? [] : ["node-role.kubernetes.io/master:NoSchedule"] - node-label = var.automatically_upgrade_k3s ? ["k3s_upgrade=true"] : [] - disable-network-policy = var.cni_plugin == "calico" ? true : var.disable_network_policy + node-name = module.control_planes[0].name + token = random_password.k3s_token.result + cluster-init = true + disable-cloud-controller = true + disable = local.disable_extras + flannel-iface = "eth1" + kubelet-arg = ["cloud-provider=external", "volume-plugin-dir=/var/lib/kubelet/volumeplugins"] + kube-controller-manager-arg = "flex-volume-plugin-dir=/var/lib/kubelet/volumeplugins" + node-ip = module.control_planes[0].private_ipv4_address + advertise-address = module.control_planes[0].private_ipv4_address + node-taint = var.allow_scheduling_on_control_plane ? [] : ["node-role.kubernetes.io/master:NoSchedule"] + node-label = var.automatically_upgrade_k3s ? ["k3s_upgrade=true"] : [] + disable-network-policy = var.cni_plugin == "calico" ? true : var.disable_network_policy }, var.cni_plugin == "calico" ? { - flannel-backend = "none" - kube-controller-manager-arg = "flex-volume-plugin-dir=/var/lib/kubelet/volumeplugins" + flannel-backend = "none" } : {})) destination = "/tmp/config.yaml" }