From 71856675a4c08a43ad1dfbab6c7124b1020788fe Mon Sep 17 00:00:00 2001 From: "Lubomir I. Ivanov" Date: Fri, 18 Sep 2020 01:03:38 +0300 Subject: [PATCH] kubeadm: remove the --kubelet-version flag for "upgrade node" The flag was deprecated as it is problematic since it allows overrides of the kubelet configuration that is downloaded from the cluster during upgrade. Kubeadm node upgrades already download the KubeletConfiguration and store it in the internal ClusterConfiguration type. It is then only a matter of writing that KubeletConfiguration to disk. --- cmd/kubeadm/app/cmd/phases/upgrade/node/data.go | 1 - .../app/cmd/phases/upgrade/node/kubeletconfig.go | 13 +------------ cmd/kubeadm/app/cmd/upgrade/node.go | 10 ---------- 3 files changed, 1 insertion(+), 23 deletions(-) diff --git a/cmd/kubeadm/app/cmd/phases/upgrade/node/data.go b/cmd/kubeadm/app/cmd/phases/upgrade/node/data.go index 91339d9aec2..2568d00f566 100644 --- a/cmd/kubeadm/app/cmd/phases/upgrade/node/data.go +++ b/cmd/kubeadm/app/cmd/phases/upgrade/node/data.go @@ -28,7 +28,6 @@ type Data interface { EtcdUpgrade() bool RenewCerts() bool DryRun() bool - KubeletVersion() string Cfg() *kubeadmapi.InitConfiguration IsControlPlaneNode() bool Client() clientset.Interface diff --git a/cmd/kubeadm/app/cmd/phases/upgrade/node/kubeletconfig.go b/cmd/kubeadm/app/cmd/phases/upgrade/node/kubeletconfig.go index e6a50d7d8c8..d4602fea94d 100644 --- a/cmd/kubeadm/app/cmd/phases/upgrade/node/kubeletconfig.go +++ b/cmd/kubeadm/app/cmd/phases/upgrade/node/kubeletconfig.go @@ -50,7 +50,6 @@ func NewKubeletConfigPhase() workflow.Phase { InheritFlags: []string{ options.DryRun, options.KubeconfigPath, - options.KubeletVersion, }, } return phase @@ -76,17 +75,7 @@ func runKubeletConfigPhase() func(c workflow.RunData) error { // TODO: Checkpoint the current configuration first so that if something goes wrong it can be recovered // Store the kubelet component configuration. - // By default the kubelet version is expected to be equal to cfg.ClusterConfiguration.KubernetesVersion, but - // users can specify a different kubelet version (this is a legacy of the original implementation - // of `kubeadm upgrade node config` which we are preserving in order to not break the GA contract) - if data.KubeletVersion() != "" && data.KubeletVersion() != cfg.ClusterConfiguration.KubernetesVersion { - fmt.Printf("[upgrade] Using kubelet config version %s, while kubernetes-version is %s\n", data.KubeletVersion(), cfg.ClusterConfiguration.KubernetesVersion) - if err := kubeletphase.DownloadConfig(data.Client(), data.KubeletVersion(), kubeletDir); err != nil { - return err - } - - // WriteConfigToDisk is what we should be calling since we already have the correct component config loaded - } else if err = kubeletphase.WriteConfigToDisk(&cfg.ClusterConfiguration, kubeletDir); err != nil { + if err = kubeletphase.WriteConfigToDisk(&cfg.ClusterConfiguration, kubeletDir); err != nil { return err } diff --git a/cmd/kubeadm/app/cmd/upgrade/node.go b/cmd/kubeadm/app/cmd/upgrade/node.go index 6103d780938..d3d013177d2 100644 --- a/cmd/kubeadm/app/cmd/upgrade/node.go +++ b/cmd/kubeadm/app/cmd/upgrade/node.go @@ -39,7 +39,6 @@ import ( // supported by this api will be exposed as a flag. type nodeOptions struct { kubeConfigPath string - kubeletVersion string etcdUpgrade bool renewCerts bool dryRun bool @@ -57,7 +56,6 @@ type nodeData struct { etcdUpgrade bool renewCerts bool dryRun bool - kubeletVersion string cfg *kubeadmapi.InitConfiguration isControlPlaneNode bool client clientset.Interface @@ -117,8 +115,6 @@ func newNodeOptions() *nodeOptions { func addUpgradeNodeFlags(flagSet *flag.FlagSet, nodeOptions *nodeOptions) { options.AddKubeConfigFlag(flagSet, &nodeOptions.kubeConfigPath) flagSet.BoolVar(&nodeOptions.dryRun, options.DryRun, nodeOptions.dryRun, "Do not change any state, just output the actions that would be performed.") - flagSet.StringVar(&nodeOptions.kubeletVersion, options.KubeletVersion, nodeOptions.kubeletVersion, "The *desired* version for the kubelet config after the upgrade. If not specified, the KubernetesVersion from the kubeadm-config ConfigMap will be used") - flagSet.MarkDeprecated(options.KubeletVersion, "This flag is deprecated and will be removed in a future version.") flagSet.BoolVar(&nodeOptions.renewCerts, options.CertificateRenewal, nodeOptions.renewCerts, "Perform the renewal of certificates used by component changed during upgrades.") flagSet.BoolVar(&nodeOptions.etcdUpgrade, options.EtcdUpgrade, nodeOptions.etcdUpgrade, "Perform the upgrade of etcd.") flagSet.StringSliceVar(&nodeOptions.ignorePreflightErrors, options.IgnorePreflightErrors, nodeOptions.ignorePreflightErrors, "A list of checks whose errors will be shown as warnings. Example: 'IsPrivilegedUser,Swap'. Value 'all' ignores errors from all checks.") @@ -160,7 +156,6 @@ func newNodeData(cmd *cobra.Command, args []string, options *nodeOptions) (*node etcdUpgrade: options.etcdUpgrade, renewCerts: options.renewCerts, dryRun: options.dryRun, - kubeletVersion: options.kubeletVersion, cfg: cfg, client: client, isControlPlaneNode: isControlPlaneNode, @@ -185,11 +180,6 @@ func (d *nodeData) RenewCerts() bool { return d.renewCerts } -// KubeletVersion returns the kubeletVersion flag. -func (d *nodeData) KubeletVersion() string { - return d.kubeletVersion -} - // Cfg returns initConfiguration. func (d *nodeData) Cfg() *kubeadmapi.InitConfiguration { return d.cfg