Skip to content

Commit b406ba5

Browse files
committed
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'.
1 parent 7bfdda4 commit b406ba5

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

cmd/kubeadm/app/cmd/phases/upgrade/addons.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,20 @@ func getInitData(c workflow.RunData) (*kubeadmapi.InitConfiguration, clientset.I
8383

8484
// runCoreDNSAddon upgrades the CoreDNS addon.
8585
func runCoreDNSAddon(c workflow.RunData) error {
86+
const skipMessagePrefix = "[upgrade/addon] Skipping the addon/coredns phase."
87+
8688
cfg, client, patchesDir, out, dryRun, isControlPlaneNode, err := getInitData(c)
8789
if err != nil {
8890
return err
8991
}
9092

9193
if !isControlPlaneNode {
92-
fmt.Println("[upgrade/addon] Skipping addon/coredns phase. Not a control plane node.")
94+
fmt.Fprintf(out, "%s Not a control plane node.\n", skipMessagePrefix)
95+
return nil
96+
}
97+
98+
if cfg.ClusterConfiguration.DNS.Disabled {
99+
fmt.Fprintf(out, "%s The addon is disabled.\n", skipMessagePrefix)
93100
return nil
94101
}
95102

@@ -110,13 +117,20 @@ func runCoreDNSAddon(c workflow.RunData) error {
110117

111118
// runKubeProxyAddon upgrades the kube-proxy addon.
112119
func runKubeProxyAddon(c workflow.RunData) error {
120+
const skipMessagePrefix = "[upgrade/addon] Skipping the addon/kube-proxy phase."
121+
113122
cfg, client, _, out, dryRun, isControlPlaneNode, err := getInitData(c)
114123
if err != nil {
115124
return err
116125
}
117126

118127
if !isControlPlaneNode {
119-
fmt.Println("[upgrade/addon] Skipping addon/kube-proxy phase. Not a control plane node.")
128+
fmt.Fprintf(out, "%s Not a control plane node.\n", skipMessagePrefix)
129+
return nil
130+
}
131+
132+
if cfg.ClusterConfiguration.Proxy.Disabled {
133+
fmt.Fprintf(out, "%s The addon is disabled.\n", skipMessagePrefix)
120134
return nil
121135
}
122136

0 commit comments

Comments
 (0)