-
Notifications
You must be signed in to change notification settings - Fork 1.4k
✨ Allow to disable KubeProxy and CoreDNS #12359
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
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Hi @sathieu. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
df65ac9
to
d9c128f
Compare
d9c128f
to
198850a
Compare
198850a
to
31527e7
Compare
I would like to better understand the transition from where we are today to the target state. As of today, the API only allows users to delegate to kubeadm installation of core DNS and kube-proxy, and the annotation allows users to take ownership of the management of the upgrades of those addons. With this PR, I assume we are adding a third use case, which is take ownership of both installation and management of CoreDNS and kube-proxy, but it is not clear if both the existing use cases are going to be still supported. (BTW, in my opinion we have to support all of them, and possibly more to a more consistent API). |
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.
Thank you for working on this! I left some comments.
// Proxy defines the options for the proxy add-on installed in the cluster. | ||
Proxy Proxy `json:"proxy,omitempty"` | ||
} |
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.
// Proxy defines the options for the proxy add-on installed in the cluster. | |
Proxy Proxy `json:"proxy,omitempty"` | |
} | |
// Proxy defines the options for the proxy add-on installed in the cluster. | |
// +optional | |
Proxy *Proxy `json:"proxy,omitempty"` |
This field is optional, so it would be good to add the optional marker and make it be pointer.
// Disabled specifies whether to disable this addon in the cluster | ||
Disabled bool `json:"disabled,omitempty"` |
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.
// Disabled specifies whether to disable this addon in the cluster | |
Disabled bool `json:"disabled,omitempty"` | |
// Disabled specifies whether to disable this addon in the cluster | |
// +optional | |
Disabled *bool `json:"disabled,omitempty"` |
// Disabled specifies whether to disable this addon in the cluster | ||
Disabled bool `json:"disabled,omitempty"` |
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.
// Disabled specifies whether to disable this addon in the cluster | |
Disabled bool `json:"disabled,omitempty"` | |
// Disabled specifies whether to disable this addon in the cluster | |
// +optional | |
Disabled *bool `json:"disabled,omitempty"` |
// Proxy defines the proxy addon that should be used in the cluster | ||
type Proxy struct { | ||
// Disabled specifies whether to disable this addon in the cluster | ||
Disabled bool `json:"disabled,omitempty"` |
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.
Same here.
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.
Do we need to add these changes to v1beta1 ? I think it's good way to only add these to v1beta2.
objs := []client.Object{ | ||
cluster.DeepCopy(), | ||
corednsCM.DeepCopy(), | ||
kubeadmCM.DeepCopy(), | ||
} | ||
kcp := kcp.DeepCopy() | ||
kcp.Spec.KubeadmConfigSpec.ClusterConfiguration.DNS.Disabled = true | ||
|
||
depl := depl.DeepCopy() | ||
|
||
depl.Spec.Template.Spec.Containers[0].Image = "my-cool-image!!!!" // something very unlikely for getCoreDNSInfo to parse | ||
objs = append(objs, depl) |
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.
objs := []client.Object{ | |
cluster.DeepCopy(), | |
corednsCM.DeepCopy(), | |
kubeadmCM.DeepCopy(), | |
} | |
kcp := kcp.DeepCopy() | |
kcp.Spec.KubeadmConfigSpec.ClusterConfiguration.DNS.Disabled = true | |
depl := depl.DeepCopy() | |
depl.Spec.Template.Spec.Containers[0].Image = "my-cool-image!!!!" // something very unlikely for getCoreDNSInfo to parse | |
objs = append(objs, depl) | |
depl := depl.DeepCopy() | |
depl.Spec.Template.Spec.Containers[0].Image = "my-cool-image!!!!" // something very unlikely for getCoreDNSInfo to parse | |
kcp := kcp.DeepCopy() | |
kcp.Spec.KubeadmConfigSpec.ClusterConfiguration.DNS.Disabled = true | |
objs := []client.Object{ | |
cluster.DeepCopy(), | |
corednsCM.DeepCopy(), | |
kubeadmCM.DeepCopy(), | |
depl, | |
} |
|
||
var actualCoreDNSDeployment appsv1.Deployment | ||
g.Expect(fakeClient.Get(ctx, client.ObjectKey{Name: "coredns", Namespace: metav1.NamespaceSystem}, &actualCoreDNSDeployment)).To(Succeed()) | ||
g.Expect(actualCoreDNSDeployment.Spec.Template.Spec.Containers[0].Image).ToNot(ContainSubstring("coredns")) |
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.
g.Expect(actualCoreDNSDeployment.Spec.Template.Spec.Containers[0].Image).ToNot(ContainSubstring("coredns")) | |
g.Expect(actualCoreDNSDeployment.Spec.Template.Spec.Containers[0].Image).To(Equal("my-cool-image!!!!")) |
@@ -421,6 +421,12 @@ func staticPodName(component, nodeName string) string { | |||
func (w *Workload) UpdateKubeProxyImageInfo(ctx context.Context, kcp *controlplanev1.KubeadmControlPlane) error { | |||
// Return early if we've been asked to skip kube-proxy upgrades entirely. | |||
if _, ok := kcp.Annotations[controlplanev1.SkipKubeProxyAnnotation]; ok { | |||
// |
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.
// |
// Return early if DNS is disabled | ||
if kcp.Spec.KubeadmConfigSpec.ClusterConfiguration.DNS.Disabled { | ||
return nil | ||
} | ||
|
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.
// Return early if DNS is disabled | |
if kcp.Spec.KubeadmConfigSpec.ClusterConfiguration.DNS.Disabled { | |
return nil | |
} | |
// Return early if DNS is disabled | |
if clusterCondiguration.DNS.Disabled { | |
return nil | |
} | |
We can rewrite it like suggestion when you move these codes after L-94,
31527e7
to
166d792
Compare
@fabriziopandini @sivchari Thanks for your review. @sivchari I've implemented all your suggestions. However, the pointer usage makes code less readable. Should I create helper functions and where? I've kept the v1beta1 part, because some providers have not yet migrated to v1beta2 (for example capv) |
What this PR does / why we need it:
Disabling kube-proxy using
controlplane.cluster.x-k8s.io/skip-kube-proxy
annotation is not enough because kubeadm will try to pull the kube-proxy image on preflight.The proper way to disable kube-proxy is to use
Proxy.Disable=true
, as in this PR.Which issue(s) this PR fixes:
Related to #12288
/area provider/bootstrap-kubeadm