Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kubeadm: Remove kubeadm config upload #92610

Merged
merged 1 commit into from
Jun 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 0 additions & 2 deletions cmd/kubeadm/app/cmd/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
117 changes: 0 additions & 117 deletions cmd/kubeadm/app/cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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{
Expand All @@ -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 {

Expand Down