Skip to content

feat: Add k8s version logic for external cloud-provider flag #1134

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jimmidyson
Copy link
Member

This flag has been removed from kube-apiserver in k8s v1.33 so need to
use version specific logic to add it for pre-1.33 clusters.

"patchedObjectKind", obj.GetObjectKind().GroupVersionKind().String(),
"patchedObjectName", ctrlclient.ObjectKeyFromObject(obj),
).Info(
"adding external cloud-provider flag to control plane kubeadm config template because Kubernetes < 1.33.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we see if we can get away with not providing this flag at all in previous versions?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From https://kubernetes.io/blog/2023/12/14/cloud-provider-integration-changes/#migrate-to-external-cloud-controller-managers it does look like this is required still. I'd rather be safe than sorry.

@jimmidyson jimmidyson force-pushed the jimmi/1.33-cloud-provider-external branch from c500c89 to f42ccb7 Compare May 22, 2025 17:48
This flag has been removed from kube-apiserver in k8s v1.33 so need to
use version specific logic to add it for pre-1.33 clusters.
@jimmidyson jimmidyson force-pushed the jimmi/1.33-cloud-provider-external branch from f42ccb7 to c3876bd Compare May 22, 2025 18:32
Copy link
Contributor

@dkoshkin dkoshkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for picking this up

@@ -63,17 +63,15 @@ func AssertGeneratePatches[T mutation.GeneratePatches](
}
resp := &runtimehooksv1.GeneratePatchesResponse{}
h.GeneratePatches(context.Background(), req, resp)
expectedStatus := runtimehooksv1.ResponseStatusSuccess
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really understand the intent of these changes, please reply here.

return fmt.Errorf("failed to get control plane Kubernetes version from builtin variable: %w", err)
}

cpK8sVersion, err := semver.ParseTolerant(cpVersion)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: the codebase mostly does not use "k8sVersion"

Suggested change
cpK8sVersion, err := semver.ParseTolerant(cpVersion)
kubernetesVersion, err := semver.ParseTolerant(cpVersion)


if versionGreatOrEqualTo133Range(cpK8sVersion) {
log.V(5).Info(
"skipping external cloud-provider flag to control plane kubeadm config template because Kubernetes < 1.33.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"skipping external cloud-provider flag to control plane kubeadm config template because Kubernetes < 1.33.0",
"skipping external cloud-provider flag to control plane kubeadm config template because Kubernetes <= 1.33.0",

if obj.Spec.Template.Spec.KubeadmConfigSpec.ClusterConfiguration.APIServer.ExtraArgs == nil {
obj.Spec.Template.Spec.KubeadmConfigSpec.ClusterConfiguration.APIServer.ExtraArgs = make(map[string]string, 1)
}
obj.Spec.Template.Spec.KubeadmConfigSpec.ClusterConfiguration.APIServer.ExtraArgs["cloud-provider"] = "external"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it still possible for this value to be anything else, I think it can even be set to ""? Should we only set it if the key is missing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants