mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-05 02:09:56 +00:00
kubeadm: skip addons phase on worker node
This commit is contained in:
parent
f836773540
commit
036e072e41
@ -73,21 +73,26 @@ func shouldUpgradeAddons(client clientset.Interface, cfg *kubeadmapi.InitConfigu
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func getInitData(c workflow.RunData) (*kubeadmapi.InitConfiguration, clientset.Interface, string, io.Writer, bool, error) {
|
||||
func getInitData(c workflow.RunData) (*kubeadmapi.InitConfiguration, clientset.Interface, string, io.Writer, bool, bool, error) {
|
||||
data, ok := c.(Data)
|
||||
if !ok {
|
||||
return nil, nil, "", nil, false, errors.New("addon phase invoked with an invalid data struct")
|
||||
return nil, nil, "", nil, false, false, errors.New("addon phase invoked with an invalid data struct")
|
||||
}
|
||||
return data.InitCfg(), data.Client(), data.PatchesDir(), data.OutputWriter(), data.DryRun(), nil
|
||||
return data.InitCfg(), data.Client(), data.PatchesDir(), data.OutputWriter(), data.DryRun(), data.IsControlPlaneNode(), nil
|
||||
}
|
||||
|
||||
// runCoreDNSAddon upgrades the CoreDNS addon.
|
||||
func runCoreDNSAddon(c workflow.RunData) error {
|
||||
cfg, client, patchesDir, out, dryRun, err := getInitData(c)
|
||||
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.")
|
||||
return nil
|
||||
}
|
||||
|
||||
shouldUpgradeAddons, err := shouldUpgradeAddons(client, cfg, out)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -105,11 +110,16 @@ func runCoreDNSAddon(c workflow.RunData) error {
|
||||
|
||||
// runKubeProxyAddon upgrades the kube-proxy addon.
|
||||
func runKubeProxyAddon(c workflow.RunData) error {
|
||||
cfg, client, _, out, dryRun, err := getInitData(c)
|
||||
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.")
|
||||
return nil
|
||||
}
|
||||
|
||||
shouldUpgradeAddons, err := shouldUpgradeAddons(client, cfg, out)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -36,6 +36,7 @@ func (t *testData) RenewCerts() bool { return false }
|
||||
func (t *testData) DryRun() bool { return false }
|
||||
func (t *testData) Cfg() *kubeadmapi.UpgradeConfiguration { return nil }
|
||||
func (t *testData) InitCfg() *kubeadmapi.InitConfiguration { return nil }
|
||||
func (t *testData) IsControlPlaneNode() bool { return false }
|
||||
func (t *testData) Client() clientset.Interface { return nil }
|
||||
func (t *testData) IgnorePreflightErrors() sets.Set[string] { return nil }
|
||||
func (t *testData) PatchesDir() string { return "" }
|
||||
|
@ -33,6 +33,7 @@ type Data interface {
|
||||
DryRun() bool
|
||||
Cfg() *kubeadmapi.UpgradeConfiguration
|
||||
InitCfg() *kubeadmapi.InitConfiguration
|
||||
IsControlPlaneNode() bool
|
||||
Client() clientset.Interface
|
||||
IgnorePreflightErrors() sets.Set[string]
|
||||
PatchesDir() string
|
||||
|
@ -36,6 +36,7 @@ func (t *testData) RenewCerts() bool { return false }
|
||||
func (t *testData) DryRun() bool { return false }
|
||||
func (t *testData) Cfg() *kubeadmapi.UpgradeConfiguration { return nil }
|
||||
func (t *testData) InitCfg() *kubeadmapi.InitConfiguration { return nil }
|
||||
func (t *testData) IsControlPlaneNode() bool { return false }
|
||||
func (t *testData) Client() clientset.Interface { return nil }
|
||||
func (t *testData) IgnorePreflightErrors() sets.Set[string] { return nil }
|
||||
func (t *testData) PatchesDir() string { return "" }
|
||||
|
@ -26,6 +26,5 @@ import (
|
||||
type Data interface {
|
||||
upgrade.Data
|
||||
|
||||
IsControlPlaneNode() bool
|
||||
KubeConfigPath() string
|
||||
}
|
||||
|
@ -351,3 +351,9 @@ func (d *applyData) AllowRCUpgrades() bool {
|
||||
func (d *applyData) ForceUpgrade() bool {
|
||||
return d.force
|
||||
}
|
||||
|
||||
// IsControlPlaneNode returns if the node is a control-plane node.
|
||||
func (d *applyData) IsControlPlaneNode() bool {
|
||||
// `kubeadm upgrade apply` should always be executed on a control-plane node
|
||||
return true
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user