kubeadm: update e2e tests for the kubelet-config

Add means to parse the value of UnversionedKubletConfigMap
feature gate if present and based on that decide what
configmap to look for.
This commit is contained in:
Lubomir I. Ivanov 2021-10-21 20:42:24 +03:00
parent 68118d7319
commit 17cc064f7f

View File

@ -69,6 +69,9 @@ var _ = Describe("kubelet-config ConfigMap", func() {
m := getClusterConfiguration(f.ClientSet)
// Extract the kubernetesVersion
// TODO: remove this after the UnversionedKubeletConfigMap feature gate goes GA:
// https://github.com/kubernetes/kubeadm/issues/1582
// At that point parsing the k8s version will no longer be needed in this test.
gomega.Expect(m).To(gomega.HaveKey("kubernetesVersion"))
k8sVersionString := m["kubernetesVersion"].(string)
k8sVersion, err := version.ParseSemantic(k8sVersionString)
@ -76,9 +79,31 @@ var _ = Describe("kubelet-config ConfigMap", func() {
framework.Failf("error reading kubernetesVersion from %s ConfigMap: %v", kubeadmConfigName, err)
}
// Extract the value of the UnversionedKubeletConfigMap feature gate if its present.
// TODO: remove this after the UnversionedKubeletConfigMap feature gate goes GA:
// https://github.com/kubernetes/kubeadm/issues/1582
var UnversionedKubeletConfigMap bool
if _, ok := m["featureGates"]; ok {
if featureGates, ok := m["featureGates"].(map[string]bool); ok {
// TODO: update the default to true once this graduates to Beta.
UnversionedKubeletConfigMap = false
if val, ok := featureGates["UnversionedKubeletConfigMap"]; ok {
UnversionedKubeletConfigMap = val
}
} else {
framework.Failf("unable to cast the featureGates field in the %s ConfigMap", kubeadmConfigName)
}
}
// Computes all the names derived from the kubernetesVersion
kubeletConfigConfigMapName = fmt.Sprintf("kubelet-config-%d.%d", k8sVersion.Major(), k8sVersion.Minor())
kubeletConfigRoleName = fmt.Sprintf("kubeadm:kubelet-config-%d.%d", k8sVersion.Major(), k8sVersion.Minor())
kubeletConfigConfigMapName = "kubelet-config"
kubeletConfigRoleName = "kubeadm:kubelet-config"
// TODO: remove this after the UnversionedKubeletConfigMap feature gate goes GA:
// https://github.com/kubernetes/kubeadm/issues/1582
if !UnversionedKubeletConfigMap {
kubeletConfigConfigMapName = fmt.Sprintf("kubelet-config-%d.%d", k8sVersion.Major(), k8sVersion.Minor())
kubeletConfigRoleName = fmt.Sprintf("kubeadm:kubelet-config-%d.%d", k8sVersion.Major(), k8sVersion.Minor())
}
kubeletConfigRoleBindingName = kubeletConfigRoleName
kubeletConfigConfigMapResource.Name = kubeletConfigConfigMapName
})