mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
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.
This commit is contained in:
parent
ff1d6e8c1d
commit
71856675a4
@ -28,7 +28,6 @@ type Data interface {
|
||||
EtcdUpgrade() bool
|
||||
RenewCerts() bool
|
||||
DryRun() bool
|
||||
KubeletVersion() string
|
||||
Cfg() *kubeadmapi.InitConfiguration
|
||||
IsControlPlaneNode() bool
|
||||
Client() clientset.Interface
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user