diff --git a/pkg/webhook/controlplane/ensurer.go b/pkg/webhook/controlplane/ensurer.go index d92212eab..74db56355 100644 --- a/pkg/webhook/controlplane/ensurer.go +++ b/pkg/webhook/controlplane/ensurer.go @@ -382,8 +382,9 @@ func (e *ensurer) EnsureKubeletServiceUnitOptions(ctx context.Context, gctx gcon func ensureKubeletCommandLineArgs(command []string, csiEnabled bool, kubeletVersion *semver.Version) []string { if csiEnabled { + command = extensionswebhook.EnsureStringWithPrefix(command, "--cloud-provider=", "external") + if !versionutils.ConstraintK8sGreaterEqual123.Check(kubeletVersion) { - command = extensionswebhook.EnsureStringWithPrefix(command, "--cloud-provider=", "external") command = extensionswebhook.EnsureStringWithPrefix(command, "--enable-controller-attach-detach=", "true") } } else { diff --git a/pkg/webhook/controlplane/ensurer_test.go b/pkg/webhook/controlplane/ensurer_test.go index f0228676b..a901c353e 100644 --- a/pkg/webhook/controlplane/ensurer_test.go +++ b/pkg/webhook/controlplane/ensurer_test.go @@ -510,7 +510,7 @@ var _ = Describe("Ensurer", func() { Entry("kubelet version < 1.19", eContextK8s116, semver.MustParse("1.16.0"), "openstack", false), Entry("1.19 <= kubelet version < 1.23", eContextK8s119, semver.MustParse("1.19.0"), "external", true), - Entry("kubelet version >= 1.23", eContextK8s119, semver.MustParse("1.23.0"), "", false), + Entry("kubelet version >= 1.23", eContextK8s119, semver.MustParse("1.23.0"), "external", false), ) })