diff --git a/cmd/kubeadm/app/cmd/config.go b/cmd/kubeadm/app/cmd/config.go index 89c2c455991..cc7f5c46758 100644 --- a/cmd/kubeadm/app/cmd/config.go +++ b/cmd/kubeadm/app/cmd/config.go @@ -514,10 +514,7 @@ func (i *ImagesList) Run(out io.Writer) error { // AddImagesCommonConfigFlags adds the flags that configure kubeadm (and affect the images kubeadm will use) func AddImagesCommonConfigFlags(flagSet *flag.FlagSet, cfg *kubeadmapiv1beta1.InitConfiguration, cfgPath *string, featureGatesString *string) { - flagSet.StringVar( - &cfg.ClusterConfiguration.KubernetesVersion, "kubernetes-version", cfg.ClusterConfiguration.KubernetesVersion, - `Choose a specific Kubernetes version for the control plane.`, - ) + options.AddKubernetesVersionFlag(flagSet, &cfg.ClusterConfiguration.KubernetesVersion) options.AddFeatureGatesStringFlag(flagSet, featureGatesString) flagSet.StringVar(cfgPath, "config", *cfgPath, "Path to kubeadm config file.") } diff --git a/cmd/kubeadm/app/cmd/init.go b/cmd/kubeadm/app/cmd/init.go index 28df66a11a8..bc21992201e 100644 --- a/cmd/kubeadm/app/cmd/init.go +++ b/cmd/kubeadm/app/cmd/init.go @@ -217,10 +217,9 @@ func AddInitConfigFlags(flagSet *flag.FlagSet, cfg *kubeadmapiv1beta1.InitConfig &cfg.Networking.DNSDomain, options.NetworkingDNSDomain, cfg.Networking.DNSDomain, `Use alternative domain for services, e.g. "myorg.internal".`, ) - flagSet.StringVar( - &cfg.KubernetesVersion, options.KubernetesVersion, cfg.KubernetesVersion, - `Choose a specific Kubernetes version for the control plane.`, - ) + + options.AddKubernetesVersionFlag(flagSet, &cfg.KubernetesVersion) + flagSet.StringVar( &cfg.CertificatesDir, options.CertificatesDir, cfg.CertificatesDir, `The path where to save and store the certificates.`, diff --git a/cmd/kubeadm/app/cmd/options/generic.go b/cmd/kubeadm/app/cmd/options/generic.go index 96206b9b645..b1120783c43 100644 --- a/cmd/kubeadm/app/cmd/options/generic.go +++ b/cmd/kubeadm/app/cmd/options/generic.go @@ -72,3 +72,11 @@ func AddFeatureGatesStringFlag(fs *pflag.FlagSet, featureGatesString *string) { "No feature gates are available in this release.") } } + +// AddKubernetesVersionFlag adds the --kubernetes-version flag to the given flagset +func AddKubernetesVersionFlag(fs *pflag.FlagSet, kubernetesVersion *string) { + fs.StringVar( + kubernetesVersion, KubernetesVersion, *kubernetesVersion, + `Choose a specific Kubernetes version for the control plane.`, + ) +}