From ae1dcb031f62733342c9b965bc063b08d7550e04 Mon Sep 17 00:00:00 2001
From: Calin Cristian Andrei <cristian.calin@outlook.com>
Date: Mon, 6 Jun 2022 18:10:10 +0300
Subject: [PATCH] [kubernetes] drop pre 1.22.0 workarounds

---
 .../group_vars/k8s_cluster/k8s-cluster.yml     |  7 -------
 .../templates/kubescheduler-config.yaml.j2     |  4 +---
 roles/kubernetes/node/tasks/kubelet.yml        |  9 ---------
 .../node/templates/kubelet.env.v1beta1.j2      |  3 ---
 .../preinstall/tasks/0020-verify-settings.yml  | 18 ------------------
 roles/kubespray-defaults/defaults/main.yaml    |  4 ----
 6 files changed, 1 insertion(+), 44 deletions(-)

diff --git a/inventory/sample/group_vars/k8s_cluster/k8s-cluster.yml b/inventory/sample/group_vars/k8s_cluster/k8s-cluster.yml
index 5ed394a8d..91674de2d 100644
--- a/inventory/sample/group_vars/k8s_cluster/k8s-cluster.yml
+++ b/inventory/sample/group_vars/k8s_cluster/k8s-cluster.yml
@@ -216,16 +216,9 @@ k8s_image_pull_policy: IfNotPresent
 # audit log for kubernetes
 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
 # kubelet_config_dir:
 default_kubelet_config_dir: "{{ kube_config_dir }}/dynamic_kubelet_dir"
-dynamic_kubelet_configuration_dir: "{{ kubelet_config_dir | default(default_kubelet_config_dir) }}"
 
 # pod security policy (RBAC must be enabled either by having 'RBAC' in authorization_modes or kubeadm enabled)
 podsecuritypolicy_enabled: false
diff --git a/roles/kubernetes/control-plane/templates/kubescheduler-config.yaml.j2 b/roles/kubernetes/control-plane/templates/kubescheduler-config.yaml.j2
index 4ee61da90..39b0f0557 100644
--- a/roles/kubernetes/control-plane/templates/kubescheduler-config.yaml.j2
+++ b/roles/kubernetes/control-plane/templates/kubescheduler-config.yaml.j2
@@ -1,6 +1,4 @@
-{% if kube_version is version('v1.22.0', '<') %}
-{% set kubescheduler_config_api_version = "v1beta1" %}
-{% elif kube_version is version('v1.23.0', '<') %}
+{% if kube_version is version('v1.23.0', '<') %}
 {% set kubescheduler_config_api_version = "v1beta2" %}
 {% else %}
 {% set kubescheduler_config_api_version = "v1beta3" %}
diff --git a/roles/kubernetes/node/tasks/kubelet.yml b/roles/kubernetes/node/tasks/kubelet.yml
index 3dc747c8c..c551f772d 100644
--- a/roles/kubernetes/node/tasks/kubelet.yml
+++ b/roles/kubernetes/node/tasks/kubelet.yml
@@ -1,13 +1,4 @@
 ---
-- name: Make sure dynamic kubelet configuration directory is writeable
-  file:
-    path: "{{ dynamic_kubelet_configuration_dir }}"
-    mode: 0600
-    state: directory
-  when:
-    - dynamic_kubelet_configuration
-    - kube_version is version('v1.22.0', '<')
-
 - name: Set kubelet api version to v1beta1
   set_fact:
     kubeletConfig_api_version: v1beta1
diff --git a/roles/kubernetes/node/templates/kubelet.env.v1beta1.j2 b/roles/kubernetes/node/templates/kubelet.env.v1beta1.j2
index c2030126b..c84ac88d3 100644
--- a/roles/kubernetes/node/templates/kubelet.env.v1beta1.j2
+++ b/roles/kubernetes/node/templates/kubelet.env.v1beta1.j2
@@ -18,9 +18,6 @@ KUBELET_HOSTNAME="--hostname-override={{ kube_override_hostname }}"
 --container-runtime=remote \
 --container-runtime-endpoint=unix://{{ cri_socket }} \
 {% endif %}
-{% 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 }} \
 {% endset %}
 
diff --git a/roles/kubernetes/preinstall/tasks/0020-verify-settings.yml b/roles/kubernetes/preinstall/tasks/0020-verify-settings.yml
index 108da9261..29e6b1b4a 100644
--- a/roles/kubernetes/preinstall/tasks/0020-verify-settings.yml
+++ b/roles/kubernetes/preinstall/tasks/0020-verify-settings.yml
@@ -77,16 +77,6 @@
     - not ignore_assert_errors
     - inventory_hostname in groups['kube_node']
 
-- name: Stop when dynamic_kubelet_configuration enabled for kubernetes >= 1.22
-  assert:
-    that: not dynamic_kubelet_configuration
-    msg: >
-      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.
-  when:
-    - kube_version is version('v1.22.0', '>=')
-
 # This assertion will fail on the safe side: One can indeed schedule more pods
 # on a node than the CIDR-range has space for when additional pods use the host
 # network namespace. It is impossible to ascertain the number of such pods at
@@ -270,14 +260,6 @@
     msg: "kata_containers_enabled support only for containerd and crio-o. See https://github.com/kata-containers/documentation/blob/1.11.4/how-to/run-kata-with-k8s.md#install-a-cri-implementation for details"
   when: kata_containers_enabled
 
-- name: Stop if kata_containers_version is >= 2.3.0 and kube_version < 1.22.0
-  assert:
-    that: kube_version is version('v1.22.0', '>')
-    msg: "Kata containers version 2.3.0 is compatible with Kubernetes 1.22.0+"
-  when:
-    - kata_containers_enabled
-    - kata_containers_version is version ('2.3.0', '>=')
-
 - name: Stop if gvisor_enabled is enabled when container_manager is not containerd
   assert:
     that: container_manager == 'containerd'
diff --git a/roles/kubespray-defaults/defaults/main.yaml b/roles/kubespray-defaults/defaults/main.yaml
index d557dd5f9..35accf6c2 100644
--- a/roles/kubespray-defaults/defaults/main.yaml
+++ b/roles/kubespray-defaults/defaults/main.yaml
@@ -244,13 +244,9 @@ kube_override_hostname: >-
   {{ inventory_hostname }}
   {%- endif -%}
 
-# dynamic kubelet configuration
-dynamic_kubelet_configuration: false
-
 # define kubelet config dir for dynamic kubelet
 # kubelet_config_dir:
 default_kubelet_config_dir: "{{ kube_config_dir }}/dynamic_kubelet_dir"
-dynamic_kubelet_configuration_dir: "{{ kubelet_config_dir | default(default_kubelet_config_dir) }}"
 
 # Aggregator
 kube_api_aggregator_routing: false
-- 
GitLab