-
Notifications
You must be signed in to change notification settings - Fork 7
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
base: main
Are you sure you want to change the base?
Conversation
"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", |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
c500c89
to
f42ccb7
Compare
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.
f42ccb7
to
c3876bd
Compare
There was a problem hiding this 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 |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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"
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", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"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" |
There was a problem hiding this comment.
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?
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.