From b51f2c1d1c996dafbaf4f8f730770bf65aa93efc Mon Sep 17 00:00:00 2001 From: "Rostislav M. Georgiev" Date: Mon, 29 Jun 2020 18:27:48 +0300 Subject: [PATCH] kubeadm: Remove `kubeadm config upload` `kubeadm config upload` is a GA command that has been deprecated and scheduled for removal since Kubernetes 1.15 (released 06/19/2019). This change will finally removed it in Kubernetes 1.19 (planned for August 2020). The original command has long since been replaced by a GA init phase: `kubeadm init phase upload-config` Signed-off-by: Rostislav M. Georgiev --- cmd/kubeadm/app/cmd/BUILD | 2 - cmd/kubeadm/app/cmd/config.go | 117 ---------------------------------- 2 files changed, 119 deletions(-) diff --git a/cmd/kubeadm/app/cmd/BUILD b/cmd/kubeadm/app/cmd/BUILD index 775fffb6409..2773bcee8f8 100644 --- a/cmd/kubeadm/app/cmd/BUILD +++ b/cmd/kubeadm/app/cmd/BUILD @@ -23,7 +23,6 @@ go_library( "//cmd/kubeadm/app/apis/output/v1alpha1:go_default_library", "//cmd/kubeadm/app/cmd/alpha:go_default_library", "//cmd/kubeadm/app/cmd/options:go_default_library", - "//cmd/kubeadm/app/cmd/phases:go_default_library", "//cmd/kubeadm/app/cmd/phases/init:go_default_library", "//cmd/kubeadm/app/cmd/phases/join:go_default_library", "//cmd/kubeadm/app/cmd/phases/reset:go_default_library", @@ -38,7 +37,6 @@ go_library( "//cmd/kubeadm/app/phases/bootstraptoken/node:go_default_library", "//cmd/kubeadm/app/phases/certs:go_default_library", "//cmd/kubeadm/app/phases/kubeconfig:go_default_library", - "//cmd/kubeadm/app/phases/uploadconfig:go_default_library", "//cmd/kubeadm/app/util:go_default_library", "//cmd/kubeadm/app/util/apiclient:go_default_library", "//cmd/kubeadm/app/util/config:go_default_library", diff --git a/cmd/kubeadm/app/cmd/config.go b/cmd/kubeadm/app/cmd/config.go index 610f5a35d74..73bdd809223 100644 --- a/cmd/kubeadm/app/cmd/config.go +++ b/cmd/kubeadm/app/cmd/config.go @@ -41,13 +41,11 @@ import ( outputapischeme "k8s.io/kubernetes/cmd/kubeadm/app/apis/output/scheme" outputapiv1alpha1 "k8s.io/kubernetes/cmd/kubeadm/app/apis/output/v1alpha1" "k8s.io/kubernetes/cmd/kubeadm/app/cmd/options" - phaseutil "k8s.io/kubernetes/cmd/kubeadm/app/cmd/phases" cmdutil "k8s.io/kubernetes/cmd/kubeadm/app/cmd/util" "k8s.io/kubernetes/cmd/kubeadm/app/componentconfigs" "k8s.io/kubernetes/cmd/kubeadm/app/constants" "k8s.io/kubernetes/cmd/kubeadm/app/features" "k8s.io/kubernetes/cmd/kubeadm/app/images" - "k8s.io/kubernetes/cmd/kubeadm/app/phases/uploadconfig" configutil "k8s.io/kubernetes/cmd/kubeadm/app/util/config" kubeconfigutil "k8s.io/kubernetes/cmd/kubeadm/app/util/kubeconfig" "k8s.io/kubernetes/cmd/kubeadm/app/util/output" @@ -91,7 +89,6 @@ func NewCmdConfig(out io.Writer) *cobra.Command { kubeConfigFile = cmdutil.GetKubeConfigPath(kubeConfigFile) cmd.AddCommand(NewCmdConfigPrint(out)) cmd.AddCommand(NewCmdConfigMigrate(out)) - cmd.AddCommand(NewCmdConfigUpload(out, &kubeConfigFile)) cmd.AddCommand(NewCmdConfigView(out, &kubeConfigFile)) cmd.AddCommand(NewCmdConfigImages(out)) return cmd @@ -303,21 +300,6 @@ func NewCmdConfigMigrate(out io.Writer) *cobra.Command { return cmd } -// NewCmdConfigUpload (Deprecated) returns cobra.Command for "kubeadm config upload" command -// Deprecated: please see kubeadm init phase upload-config -func NewCmdConfigUpload(out io.Writer, kubeConfigFile *string) *cobra.Command { - cmd := &cobra.Command{ - Deprecated: "please see kubeadm init phase upload-config", - Use: "upload", - Short: "Upload configuration about the current state, so that 'kubeadm upgrade' can later know how to configure the upgraded cluster", - RunE: cmdutil.SubCmdRunE("upload"), - } - - cmd.AddCommand(NewCmdConfigUploadFromFile(out, kubeConfigFile)) - cmd.AddCommand(NewCmdConfigUploadFromFlags(out, kubeConfigFile)) - return cmd -} - // NewCmdConfigView returns cobra.Command for "kubeadm config view" command func NewCmdConfigView(out io.Writer, kubeConfigFile *string) *cobra.Command { return &cobra.Command{ @@ -341,105 +323,6 @@ func NewCmdConfigView(out io.Writer, kubeConfigFile *string) *cobra.Command { } } -// NewCmdConfigUploadFromFile verifies given Kubernetes config file and returns cobra.Command for -// "kubeadm config upload from-file" command -// Deprecated: please see kubeadm init phase upload-config -func NewCmdConfigUploadFromFile(out io.Writer, kubeConfigFile *string) *cobra.Command { - var cfgPath string - cmd := &cobra.Command{ - Deprecated: "please see kubeadm init phase upload-config", - Use: "from-file", - Short: "Upload a configuration file to the in-cluster ConfigMap for kubeadm configuration", - Long: fmt.Sprintf(dedent.Dedent(` - Using this command, you can upload configuration to the ConfigMap in the cluster using the same config file you gave to 'kubeadm init'. - If you initialized your cluster using a v1.7.x or lower kubeadm client and used the --config option, you need to run this command with the - same config file before upgrading to v1.8 using 'kubeadm upgrade'. - - The configuration is located in the %q namespace in the %q ConfigMap. - `), metav1.NamespaceSystem, constants.KubeadmConfigConfigMap), - RunE: func(cmd *cobra.Command, args []string) error { - if len(cfgPath) == 0 { - return errors.New("the --config flag is mandatory") - } - - klog.V(1).Infoln("[config] retrieving ClientSet from file") - client, err := kubeconfigutil.ClientSetFromFile(*kubeConfigFile) - if err != nil { - return err - } - - // Default both statically and dynamically, convert to internal API type, and validate everything - internalcfg, err := configutil.LoadInitConfigurationFromFile(cfgPath) - if err != nil { - return err - } - - // Upload the configuration using the file - klog.V(1).Infof("[config] uploading configuration") - return uploadconfig.UploadConfiguration(internalcfg, client) - }, - Args: cobra.NoArgs, - } - options.AddConfigFlag(cmd.Flags(), &cfgPath) - return cmd -} - -// NewCmdConfigUploadFromFlags returns cobra.Command for "kubeadm config upload from-flags" command -// Deprecated: please see kubeadm init phase upload-config -func NewCmdConfigUploadFromFlags(out io.Writer, kubeConfigFile *string) *cobra.Command { - initCfg := &kubeadmapiv1beta2.InitConfiguration{} - kubeadmscheme.Scheme.Default(initCfg) - - clusterCfg := &kubeadmapiv1beta2.ClusterConfiguration{} - kubeadmscheme.Scheme.Default(clusterCfg) - - var featureGatesString string - - cmd := &cobra.Command{ - Deprecated: "please see kubeadm init phase upload-config", - Use: "from-flags", - Short: "Create the in-cluster configuration file for the first time from using flags", - Long: fmt.Sprintf(dedent.Dedent(` - Using this command, you can upload configuration to the ConfigMap in the cluster using the same flags you gave to 'kubeadm init'. - If you initialized your cluster using a v1.7.x or lower kubeadm client and set certain flags, you need to run this command with the - same flags before upgrading to v1.8 using 'kubeadm upgrade'. - - The configuration is located in the %q namespace in the %q ConfigMap. - `), metav1.NamespaceSystem, constants.KubeadmConfigConfigMap), - RunE: func(cmd *cobra.Command, args []string) error { - var err error - klog.V(1).Infoln("[config] creating new FeatureGates") - if clusterCfg.FeatureGates, err = features.NewFeatureGate(&features.InitFeatureGates, featureGatesString); err != nil { - return nil - } - klog.V(1).Infoln("[config] retrieving ClientSet from file") - client, err := kubeconfigutil.ClientSetFromFile(*kubeConfigFile) - if err != nil { - return err - } - - // KubernetesVersion is not used, but we set it explicitly to avoid the lookup - // of the version from the internet when executing DefaultedInitConfiguration - phaseutil.SetKubernetesVersion(clusterCfg) - - // Default both statically and dynamically, convert to internal API type, and validate everything - klog.V(1).Infoln("[config] converting to internal API type") - internalcfg, err := configutil.DefaultedInitConfiguration(initCfg, clusterCfg) - if err != nil { - return err - } - - // Finally, upload the configuration - klog.V(1).Infof("[config] uploading configuration") - return uploadconfig.UploadConfiguration(internalcfg, client) - }, - Args: cobra.NoArgs, - } - AddInitConfigFlags(cmd.PersistentFlags(), initCfg) - AddClusterConfigFlags(cmd.PersistentFlags(), clusterCfg, &featureGatesString) - return cmd -} - // RunConfigView gets the configuration persisted in the cluster func RunConfigView(out io.Writer, client clientset.Interface) error {