kubeadm: skip disabled addons in clusterconfig on upgrade

If an addon is disabled in the ClusterConfiguration skip it
on upgrade in the repsective subphase of 'addons'.
This commit is contained in:
Lubomir I. Ivanov 2024-12-28 12:20:00 +02:00
parent 826f0910e4
commit 6fba589914

View File

@ -83,13 +83,20 @@ func getInitData(c workflow.RunData) (*kubeadmapi.InitConfiguration, clientset.I
// runCoreDNSAddon upgrades the CoreDNS addon.
func runCoreDNSAddon(c workflow.RunData) error {
const skipMessagePrefix = "[upgrade/addon] Skipping the addon/coredns phase."
cfg, client, patchesDir, out, dryRun, isControlPlaneNode, err := getInitData(c)
if err != nil {
return err
}
if !isControlPlaneNode {
fmt.Println("[upgrade/addon] Skipping addon/coredns phase. Not a control plane node.")
fmt.Fprintf(out, "%s Not a control plane node.\n", skipMessagePrefix)
return nil
}
if cfg.ClusterConfiguration.DNS.Disabled {
fmt.Fprintf(out, "%s The addon is disabled.\n", skipMessagePrefix)
return nil
}
@ -110,13 +117,20 @@ func runCoreDNSAddon(c workflow.RunData) error {
// runKubeProxyAddon upgrades the kube-proxy addon.
func runKubeProxyAddon(c workflow.RunData) error {
const skipMessagePrefix = "[upgrade/addon] Skipping the addon/kube-proxy phase."
cfg, client, _, out, dryRun, isControlPlaneNode, err := getInitData(c)
if err != nil {
return err
}
if !isControlPlaneNode {
fmt.Println("[upgrade/addon] Skipping addon/kube-proxy phase. Not a control plane node.")
fmt.Fprintf(out, "%s Not a control plane node.\n", skipMessagePrefix)
return nil
}
if cfg.ClusterConfiguration.Proxy.Disabled {
fmt.Fprintf(out, "%s The addon is disabled.\n", skipMessagePrefix)
return nil
}