diff --git a/inventory/sample/group_vars/k8s_cluster/k8s-cluster.yml b/inventory/sample/group_vars/k8s_cluster/k8s-cluster.yml index 064082246cb..e1208fc546e 100644 --- a/inventory/sample/group_vars/k8s_cluster/k8s-cluster.yml +++ b/inventory/sample/group_vars/k8s_cluster/k8s-cluster.yml @@ -211,6 +211,9 @@ k8s_image_pull_policy: IfNotPresent kubernetes_audit: false # dynamic kubelet configuration +# Note: Feature DynamicKubeletConfig is deprecated in 1.22 and will not move to GA. +# It is planned to be removed from Kubernetes in the version 1.23. +# Please use alternative ways to update kubelet configuration. dynamic_kubelet_configuration: false # define kubelet config dir for dynamic kubelet diff --git a/roles/kubernetes/node/tasks/kubelet.yml b/roles/kubernetes/node/tasks/kubelet.yml index 6e0052db989..3dc747c8c39 100644 --- a/roles/kubernetes/node/tasks/kubelet.yml +++ b/roles/kubernetes/node/tasks/kubelet.yml @@ -4,7 +4,9 @@ path: "{{ dynamic_kubelet_configuration_dir }}" mode: 0600 state: directory - when: dynamic_kubelet_configuration + when: + - dynamic_kubelet_configuration + - kube_version is version('v1.22.0', '<') - name: Set kubelet api version to v1beta1 set_fact: diff --git a/roles/kubernetes/node/templates/kubelet.env.v1beta1.j2 b/roles/kubernetes/node/templates/kubelet.env.v1beta1.j2 index 3ca1ffdd79f..d190b1f3aab 100644 --- a/roles/kubernetes/node/templates/kubelet.env.v1beta1.j2 +++ b/roles/kubernetes/node/templates/kubelet.env.v1beta1.j2 @@ -18,7 +18,7 @@ KUBELET_HOSTNAME="--hostname-override={{ kube_override_hostname }}" --container-runtime=remote \ --container-runtime-endpoint=unix://{{ cri_socket }} \ {% endif %} -{% if dynamic_kubelet_configuration %} +{% if dynamic_kubelet_configuration and kube_version is version('v1.22.0', '<') %} --dynamic-config-dir={{ dynamic_kubelet_configuration_dir }} \ {% endif %} --runtime-cgroups={{ kubelet_runtime_cgroups }} \ diff --git a/tests/files/packet_oracle7-canal-ha.yml b/tests/files/packet_oracle7-canal-ha.yml index 993bcf3dd6b..4ef58bcac6d 100644 --- a/tests/files/packet_oracle7-canal-ha.yml +++ b/tests/files/packet_oracle7-canal-ha.yml @@ -6,7 +6,7 @@ mode: ha # Kubespray settings calico_datastore: etcd kube_network_plugin: canal -dynamic_kubelet_configuration: true +#dynamic_kubelet_configuration: true deploy_netchecker: true dns_min_replicas: 1 diff --git a/tests/files/packet_ubuntu16-canal-kubeadm-ha.yml b/tests/files/packet_ubuntu16-canal-kubeadm-ha.yml index 7b27b4baedc..bb0460dca9f 100644 --- a/tests/files/packet_ubuntu16-canal-kubeadm-ha.yml +++ b/tests/files/packet_ubuntu16-canal-kubeadm-ha.yml @@ -6,6 +6,6 @@ mode: ha # Kubespray settings calico_datastore: etcd kube_network_plugin: canal -dynamic_kubelet_configuration: true +#dynamic_kubelet_configuration: true deploy_netchecker: true dns_min_replicas: 1