Add correct kubelet-arg & set /var/lib/kubelet/volumeplugins in general

This commit is contained in:
Philipp 2022-04-10 21:42:04 +02:00
parent f4dc291429
commit 8615d36cda
No known key found for this signature in database
GPG Key ID: 24A7501396EB5432
3 changed files with 31 additions and 35 deletions

View File

@ -44,19 +44,15 @@ resource "null_resource" "agents" {
# Generating k3s agent config file # Generating k3s agent config file
provisioner "file" { provisioner "file" {
content = yamlencode(merge({ content = yamlencode({
node-name = module.agents[each.key].name node-name = module.agents[each.key].name
server = "https://${module.control_planes[0].private_ipv4_address}:6443" server = "https://${module.control_planes[0].private_ipv4_address}:6443"
token = random_password.k3s_token.result 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" flannel-iface = "eth1"
node-ip = module.agents[each.key].private_ipv4_address node-ip = module.agents[each.key].private_ipv4_address
node-label = var.automatically_upgrade_k3s ? ["k3s_upgrade=true"] : [] 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" destination = "/tmp/config.yaml"
} }

View File

@ -44,22 +44,22 @@ resource "null_resource" "control_planes" {
# Generating k3s server config file # Generating k3s server config file
provisioner "file" { provisioner "file" {
content = yamlencode(merge({ content = yamlencode(merge({
node-name = module.control_planes[count.index].name node-name = module.control_planes[count.index].name
server = "https://${element(module.control_planes.*.private_ipv4_address, count.index > 0 ? 0 : 1)}:6443" server = "https://${element(module.control_planes.*.private_ipv4_address, count.index > 0 ? 0 : 1)}:6443"
token = random_password.k3s_token.result token = random_password.k3s_token.result
disable-cloud-controller = true disable-cloud-controller = true
disable = local.disable_extras disable = local.disable_extras
flannel-iface = "eth1" flannel-iface = "eth1"
kubelet-arg = "cloud-provider=external" kubelet-arg = ["cloud-provider=external", "volume-plugin-dir=/var/lib/kubelet/volumeplugins"]
node-ip = module.control_planes[count.index].private_ipv4_address kube-controller-manager-arg = "flex-volume-plugin-dir=/var/lib/kubelet/volumeplugins"
advertise-address = module.control_planes[count.index].private_ipv4_address node-ip = module.control_planes[count.index].private_ipv4_address
node-taint = var.allow_scheduling_on_control_plane ? [] : ["node-role.kubernetes.io/master:NoSchedule"] advertise-address = module.control_planes[count.index].private_ipv4_address
node-label = var.automatically_upgrade_k3s ? ["k3s_upgrade=true"] : [] node-taint = var.allow_scheduling_on_control_plane ? [] : ["node-role.kubernetes.io/master:NoSchedule"]
disable-network-policy = var.cni_plugin == "calico" ? true : var.disable_network_policy 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" ? { var.cni_plugin == "calico" ? {
flannel-backend = "none" flannel-backend = "none"
kube-controller-manager-arg = "flex-volume-plugin-dir=/var/lib/kubelet/volumeplugins"
} : {})) } : {}))
destination = "/tmp/config.yaml" destination = "/tmp/config.yaml"
} }

28
init.tf
View File

@ -9,22 +9,22 @@ resource "null_resource" "first_control_plane" {
# Generating k3s master config file # Generating k3s master config file
provisioner "file" { provisioner "file" {
content = yamlencode(merge({ content = yamlencode(merge({
node-name = module.control_planes[0].name node-name = module.control_planes[0].name
token = random_password.k3s_token.result token = random_password.k3s_token.result
cluster-init = true cluster-init = true
disable-cloud-controller = true disable-cloud-controller = true
disable = local.disable_extras disable = local.disable_extras
flannel-iface = "eth1" flannel-iface = "eth1"
kubelet-arg = "cloud-provider=external" kubelet-arg = ["cloud-provider=external", "volume-plugin-dir=/var/lib/kubelet/volumeplugins"]
node-ip = module.control_planes[0].private_ipv4_address kube-controller-manager-arg = "flex-volume-plugin-dir=/var/lib/kubelet/volumeplugins"
advertise-address = module.control_planes[0].private_ipv4_address node-ip = module.control_planes[0].private_ipv4_address
node-taint = var.allow_scheduling_on_control_plane ? [] : ["node-role.kubernetes.io/master:NoSchedule"] advertise-address = module.control_planes[0].private_ipv4_address
node-label = var.automatically_upgrade_k3s ? ["k3s_upgrade=true"] : [] node-taint = var.allow_scheduling_on_control_plane ? [] : ["node-role.kubernetes.io/master:NoSchedule"]
disable-network-policy = var.cni_plugin == "calico" ? true : var.disable_network_policy 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" ? { var.cni_plugin == "calico" ? {
flannel-backend = "none" flannel-backend = "none"
kube-controller-manager-arg = "flex-volume-plugin-dir=/var/lib/kubelet/volumeplugins"
} : {})) } : {}))
destination = "/tmp/config.yaml" destination = "/tmp/config.yaml"
} }