diff --git a/completers/kubeadm_completer/cmd/alpha.go b/completers/kubeadm_completer/cmd/alpha.go index b8c8b072..c5403f0b 100644 --- a/completers/kubeadm_completer/cmd/alpha.go +++ b/completers/kubeadm_completer/cmd/alpha.go @@ -13,5 +13,6 @@ var alphaCmd = &cobra.Command{ func init() { carapace.Gen(alphaCmd).Standalone() + rootCmd.AddCommand(alphaCmd) } diff --git a/completers/kubeadm_completer/cmd/certs.go b/completers/kubeadm_completer/cmd/certs.go index be081a0c..c0595427 100644 --- a/completers/kubeadm_completer/cmd/certs.go +++ b/completers/kubeadm_completer/cmd/certs.go @@ -13,5 +13,6 @@ var certsCmd = &cobra.Command{ func init() { carapace.Gen(certsCmd).Standalone() + rootCmd.AddCommand(certsCmd) } diff --git a/completers/kubeadm_completer/cmd/certs_certificateKey.go b/completers/kubeadm_completer/cmd/certs_certificateKey.go index 369978e7..475d6e54 100644 --- a/completers/kubeadm_completer/cmd/certs_certificateKey.go +++ b/completers/kubeadm_completer/cmd/certs_certificateKey.go @@ -13,5 +13,6 @@ var certs_certificateKeyCmd = &cobra.Command{ func init() { carapace.Gen(certs_certificateKeyCmd).Standalone() + certsCmd.AddCommand(certs_certificateKeyCmd) } diff --git a/completers/kubeadm_completer/cmd/certs_checkExpiration.go b/completers/kubeadm_completer/cmd/certs_checkExpiration.go index cae3fec2..35741451 100644 --- a/completers/kubeadm_completer/cmd/certs_checkExpiration.go +++ b/completers/kubeadm_completer/cmd/certs_checkExpiration.go @@ -2,6 +2,7 @@ package cmd import ( "github.com/carapace-sh/carapace" + "github.com/carapace-sh/carapace-bin/pkg/actions/tools/kubeadm" "github.com/spf13/cobra" ) @@ -13,14 +14,19 @@ var certs_checkExpirationCmd = &cobra.Command{ func init() { carapace.Gen(certs_checkExpirationCmd).Standalone() - certs_checkExpirationCmd.Flags().String("cert-dir", "/etc/kubernetes/pki", "The path where to save the certificates") + + certs_checkExpirationCmd.Flags().Bool("allow-missing-template-keys", false, "If true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats.") + certs_checkExpirationCmd.Flags().String("cert-dir", "", "The path where to save the certificates") certs_checkExpirationCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") - certs_checkExpirationCmd.Flags().String("kubeconfig", "/etc/kubernetes/admin.conf", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") + certs_checkExpirationCmd.Flags().String("kubeconfig", "", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") + certs_checkExpirationCmd.Flags().StringP("output", "o", "", "Output format. One of: text|json|yaml|go-template|go-template-file|template|templatefile|jsonpath|jsonpath-as-json|jsonpath-file.") + certs_checkExpirationCmd.Flags().Bool("show-managed-fields", false, "If true, keep the managedFields when printing objects in JSON or YAML format.") certsCmd.AddCommand(certs_checkExpirationCmd) carapace.Gen(certs_checkExpirationCmd).FlagCompletion(carapace.ActionMap{ "cert-dir": carapace.ActionDirectories(), "config": carapace.ActionFiles(), "kubeconfig": carapace.ActionFiles(), + "output": kubeadm.ActionOutputFormats(), }) } diff --git a/completers/kubeadm_completer/cmd/certs_generateCsr.go b/completers/kubeadm_completer/cmd/certs_generateCsr.go index 86f3b7d1..8af7a399 100644 --- a/completers/kubeadm_completer/cmd/certs_generateCsr.go +++ b/completers/kubeadm_completer/cmd/certs_generateCsr.go @@ -13,9 +13,10 @@ var certs_generateCsrCmd = &cobra.Command{ func init() { carapace.Gen(certs_generateCsrCmd).Standalone() + certs_generateCsrCmd.Flags().String("cert-dir", "", "The path where to save the certificates") certs_generateCsrCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") - certs_generateCsrCmd.Flags().String("kubeconfig-dir", "/etc/kubernetes", "The path where to save the kubeconfig file.") + certs_generateCsrCmd.Flags().String("kubeconfig-dir", "", "The path where to save the kubeconfig file.") certsCmd.AddCommand(certs_generateCsrCmd) carapace.Gen(certs_generateCsrCmd).FlagCompletion(carapace.ActionMap{ diff --git a/completers/kubeadm_completer/cmd/certs_renew.go b/completers/kubeadm_completer/cmd/certs_renew.go index 19593c0f..cd2eb704 100644 --- a/completers/kubeadm_completer/cmd/certs_renew.go +++ b/completers/kubeadm_completer/cmd/certs_renew.go @@ -13,5 +13,6 @@ var certs_renewCmd = &cobra.Command{ func init() { carapace.Gen(certs_renewCmd).Standalone() + certsCmd.AddCommand(certs_renewCmd) } diff --git a/completers/kubeadm_completer/cmd/certs_renew_adminConf.go b/completers/kubeadm_completer/cmd/certs_renew_adminConf.go index 1ce564ae..2383d22e 100644 --- a/completers/kubeadm_completer/cmd/certs_renew_adminConf.go +++ b/completers/kubeadm_completer/cmd/certs_renew_adminConf.go @@ -13,9 +13,10 @@ var certs_renew_adminConfCmd = &cobra.Command{ func init() { carapace.Gen(certs_renew_adminConfCmd).Standalone() - certs_renew_adminConfCmd.Flags().String("cert-dir", "/etc/kubernetes/pki", "The path where to save the certificates") + + certs_renew_adminConfCmd.Flags().String("cert-dir", "", "The path where to save the certificates") certs_renew_adminConfCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") - certs_renew_adminConfCmd.Flags().String("kubeconfig", "/etc/kubernetes/admin.conf", "The kubeconfig file to use when talking to the cluster.") + certs_renew_adminConfCmd.Flags().String("kubeconfig", "", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") certs_renewCmd.AddCommand(certs_renew_adminConfCmd) carapace.Gen(certs_renew_adminConfCmd).FlagCompletion(carapace.ActionMap{ diff --git a/completers/kubeadm_completer/cmd/certs_renew_all.go b/completers/kubeadm_completer/cmd/certs_renew_all.go index f86c1c70..0a231368 100644 --- a/completers/kubeadm_completer/cmd/certs_renew_all.go +++ b/completers/kubeadm_completer/cmd/certs_renew_all.go @@ -13,9 +13,10 @@ var certs_renew_allCmd = &cobra.Command{ func init() { carapace.Gen(certs_renew_allCmd).Standalone() - certs_renew_allCmd.Flags().String("cert-dir", "/etc/kubernetes/pki", "The path where to save the certificates") + + certs_renew_allCmd.Flags().String("cert-dir", "", "The path where to save the certificates") certs_renew_allCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") - certs_renew_allCmd.Flags().String("kubeconfig", "/etc/kubernetes/admin.conf", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") + certs_renew_allCmd.Flags().String("kubeconfig", "", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") certs_renewCmd.AddCommand(certs_renew_allCmd) carapace.Gen(certs_renew_allCmd).FlagCompletion(carapace.ActionMap{ diff --git a/completers/kubeadm_completer/cmd/certs_renew_apiserver.go b/completers/kubeadm_completer/cmd/certs_renew_apiserver.go index a3b96ea5..75fa02ef 100644 --- a/completers/kubeadm_completer/cmd/certs_renew_apiserver.go +++ b/completers/kubeadm_completer/cmd/certs_renew_apiserver.go @@ -13,9 +13,10 @@ var certs_renew_apiserverCmd = &cobra.Command{ func init() { carapace.Gen(certs_renew_apiserverCmd).Standalone() - certs_renew_apiserverCmd.Flags().String("cert-dir", "/etc/kubernetes/pki", "The path where to save the certificates") + + certs_renew_apiserverCmd.Flags().String("cert-dir", "", "The path where to save the certificates") certs_renew_apiserverCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") - certs_renew_apiserverCmd.Flags().String("kubeconfig", "/etc/kubernetes/admin.conf", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") + certs_renew_apiserverCmd.Flags().String("kubeconfig", "", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") certs_renewCmd.AddCommand(certs_renew_apiserverCmd) carapace.Gen(certs_renew_apiserverCmd).FlagCompletion(carapace.ActionMap{ diff --git a/completers/kubeadm_completer/cmd/certs_renew_apiserverEtcdClient.go b/completers/kubeadm_completer/cmd/certs_renew_apiserverEtcdClient.go index ce08648b..d8b1b4f7 100644 --- a/completers/kubeadm_completer/cmd/certs_renew_apiserverEtcdClient.go +++ b/completers/kubeadm_completer/cmd/certs_renew_apiserverEtcdClient.go @@ -13,9 +13,10 @@ var certs_renew_apiserverEtcdClientCmd = &cobra.Command{ func init() { carapace.Gen(certs_renew_apiserverEtcdClientCmd).Standalone() - certs_renew_apiserverEtcdClientCmd.Flags().String("cert-dir", "/etc/kubernetes/pki", "The path where to save the certificates") + + certs_renew_apiserverEtcdClientCmd.Flags().String("cert-dir", "", "The path where to save the certificates") certs_renew_apiserverEtcdClientCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") - certs_renew_apiserverEtcdClientCmd.Flags().String("kubeconfig", "/etc/kubernetes/admin.conf", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") + certs_renew_apiserverEtcdClientCmd.Flags().String("kubeconfig", "", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") certs_renewCmd.AddCommand(certs_renew_apiserverEtcdClientCmd) carapace.Gen(certs_renew_apiserverEtcdClientCmd).FlagCompletion(carapace.ActionMap{ diff --git a/completers/kubeadm_completer/cmd/certs_renew_apiserverKubeletClient.go b/completers/kubeadm_completer/cmd/certs_renew_apiserverKubeletClient.go index da0f2773..b815a65c 100644 --- a/completers/kubeadm_completer/cmd/certs_renew_apiserverKubeletClient.go +++ b/completers/kubeadm_completer/cmd/certs_renew_apiserverKubeletClient.go @@ -13,9 +13,10 @@ var certs_renew_apiserverKubeletClientCmd = &cobra.Command{ func init() { carapace.Gen(certs_renew_apiserverKubeletClientCmd).Standalone() - certs_renew_apiserverKubeletClientCmd.Flags().String("cert-dir", "/etc/kubernetes/pki", "The path where to save the certificates") + + certs_renew_apiserverKubeletClientCmd.Flags().String("cert-dir", "", "The path where to save the certificates") certs_renew_apiserverKubeletClientCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") - certs_renew_apiserverKubeletClientCmd.Flags().String("kubeconfig", "/etc/kubernetes/admin.conf", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") + certs_renew_apiserverKubeletClientCmd.Flags().String("kubeconfig", "", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") certs_renewCmd.AddCommand(certs_renew_apiserverKubeletClientCmd) carapace.Gen(certs_renew_apiserverKubeletClientCmd).FlagCompletion(carapace.ActionMap{ diff --git a/completers/kubeadm_completer/cmd/certs_renew_controllerManagerConf.go b/completers/kubeadm_completer/cmd/certs_renew_controllerManagerConf.go index 46aac687..cfe0d749 100644 --- a/completers/kubeadm_completer/cmd/certs_renew_controllerManagerConf.go +++ b/completers/kubeadm_completer/cmd/certs_renew_controllerManagerConf.go @@ -13,9 +13,10 @@ var certs_renew_controllerManagerConfCmd = &cobra.Command{ func init() { carapace.Gen(certs_renew_controllerManagerConfCmd).Standalone() - certs_renew_controllerManagerConfCmd.Flags().String("cert-dir", "/etc/kubernetes/pki", "The path where to save the certificates") + + certs_renew_controllerManagerConfCmd.Flags().String("cert-dir", "", "The path where to save the certificates") certs_renew_controllerManagerConfCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") - certs_renew_controllerManagerConfCmd.Flags().String("kubeconfig", "/etc/kubernetes/admin.conf", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") + certs_renew_controllerManagerConfCmd.Flags().String("kubeconfig", "", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") certs_renewCmd.AddCommand(certs_renew_controllerManagerConfCmd) carapace.Gen(certs_renew_controllerManagerConfCmd).FlagCompletion(carapace.ActionMap{ diff --git a/completers/kubeadm_completer/cmd/certs_renew_etcdHealthcheckClient.go b/completers/kubeadm_completer/cmd/certs_renew_etcdHealthcheckClient.go index 9aed707d..8866ee6e 100644 --- a/completers/kubeadm_completer/cmd/certs_renew_etcdHealthcheckClient.go +++ b/completers/kubeadm_completer/cmd/certs_renew_etcdHealthcheckClient.go @@ -13,9 +13,10 @@ var certs_renew_etcdHealthcheckClientCmd = &cobra.Command{ func init() { carapace.Gen(certs_renew_etcdHealthcheckClientCmd).Standalone() - certs_renew_etcdHealthcheckClientCmd.Flags().String("cert-dir", "/etc/kubernetes/pki", "The path where to save the certificates") + + certs_renew_etcdHealthcheckClientCmd.Flags().String("cert-dir", "", "The path where to save the certificates") certs_renew_etcdHealthcheckClientCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") - certs_renew_etcdHealthcheckClientCmd.Flags().String("kubeconfig", "/etc/kubernetes/admin.conf", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") + certs_renew_etcdHealthcheckClientCmd.Flags().String("kubeconfig", "", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") certs_renewCmd.AddCommand(certs_renew_etcdHealthcheckClientCmd) carapace.Gen(certs_renew_etcdHealthcheckClientCmd).FlagCompletion(carapace.ActionMap{ diff --git a/completers/kubeadm_completer/cmd/certs_renew_etcdPeer.go b/completers/kubeadm_completer/cmd/certs_renew_etcdPeer.go index af67aba7..19a3ea1a 100644 --- a/completers/kubeadm_completer/cmd/certs_renew_etcdPeer.go +++ b/completers/kubeadm_completer/cmd/certs_renew_etcdPeer.go @@ -13,9 +13,10 @@ var certs_renew_etcdPeerCmd = &cobra.Command{ func init() { carapace.Gen(certs_renew_etcdPeerCmd).Standalone() - certs_renew_etcdPeerCmd.Flags().String("cert-dir", "/etc/kubernetes/pki", "The path where to save the certificates") + + certs_renew_etcdPeerCmd.Flags().String("cert-dir", "", "The path where to save the certificates") certs_renew_etcdPeerCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") - certs_renew_etcdPeerCmd.Flags().String("kubeconfig", "/etc/kubernetes/admin.conf", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") + certs_renew_etcdPeerCmd.Flags().String("kubeconfig", "", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") certs_renewCmd.AddCommand(certs_renew_etcdPeerCmd) carapace.Gen(certs_renew_etcdPeerCmd).FlagCompletion(carapace.ActionMap{ diff --git a/completers/kubeadm_completer/cmd/certs_renew_etcdServer.go b/completers/kubeadm_completer/cmd/certs_renew_etcdServer.go index fb4e56c8..42f744ef 100644 --- a/completers/kubeadm_completer/cmd/certs_renew_etcdServer.go +++ b/completers/kubeadm_completer/cmd/certs_renew_etcdServer.go @@ -13,9 +13,10 @@ var certs_renew_etcdServerCmd = &cobra.Command{ func init() { carapace.Gen(certs_renew_etcdServerCmd).Standalone() - certs_renew_etcdServerCmd.Flags().String("cert-dir", "/etc/kubernetes/pki", "The path where to save the certificates") + + certs_renew_etcdServerCmd.Flags().String("cert-dir", "", "The path where to save the certificates") certs_renew_etcdServerCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") - certs_renew_etcdServerCmd.Flags().String("kubeconfig", "/etc/kubernetes/admin.conf", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") + certs_renew_etcdServerCmd.Flags().String("kubeconfig", "", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") certs_renewCmd.AddCommand(certs_renew_etcdServerCmd) carapace.Gen(certs_renew_etcdServerCmd).FlagCompletion(carapace.ActionMap{ diff --git a/completers/kubeadm_completer/cmd/certs_renew_frontProxyClient.go b/completers/kubeadm_completer/cmd/certs_renew_frontProxyClient.go index b41681cf..273d46b1 100644 --- a/completers/kubeadm_completer/cmd/certs_renew_frontProxyClient.go +++ b/completers/kubeadm_completer/cmd/certs_renew_frontProxyClient.go @@ -13,9 +13,10 @@ var certs_renew_frontProxyClientCmd = &cobra.Command{ func init() { carapace.Gen(certs_renew_frontProxyClientCmd).Standalone() - certs_renew_frontProxyClientCmd.Flags().String("cert-dir", "/etc/kubernetes/pki", "The path where to save the certificates") + + certs_renew_frontProxyClientCmd.Flags().String("cert-dir", "", "The path where to save the certificates") certs_renew_frontProxyClientCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") - certs_renew_frontProxyClientCmd.Flags().String("kubeconfig", "/etc/kubernetes/admin.conf", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") + certs_renew_frontProxyClientCmd.Flags().String("kubeconfig", "", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") certs_renewCmd.AddCommand(certs_renew_frontProxyClientCmd) carapace.Gen(certs_renew_frontProxyClientCmd).FlagCompletion(carapace.ActionMap{ diff --git a/completers/kubeadm_completer/cmd/certs_renew_schedulerConf.go b/completers/kubeadm_completer/cmd/certs_renew_schedulerConf.go index de64eaeb..d882967d 100644 --- a/completers/kubeadm_completer/cmd/certs_renew_schedulerConf.go +++ b/completers/kubeadm_completer/cmd/certs_renew_schedulerConf.go @@ -13,9 +13,10 @@ var certs_renew_schedulerConfCmd = &cobra.Command{ func init() { carapace.Gen(certs_renew_schedulerConfCmd).Standalone() - certs_renew_schedulerConfCmd.Flags().String("cert-dir", "/etc/kubernetes/pki", "The path where to save the certificates") + + certs_renew_schedulerConfCmd.Flags().String("cert-dir", "", "The path where to save the certificates") certs_renew_schedulerConfCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") - certs_renew_schedulerConfCmd.Flags().String("kubeconfig", "/etc/kubernetes/admin.conf", "The kubeconfig file to use when talking to the cluster.") + certs_renew_schedulerConfCmd.Flags().String("kubeconfig", "", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") certs_renewCmd.AddCommand(certs_renew_schedulerConfCmd) carapace.Gen(certs_renew_schedulerConfCmd).FlagCompletion(carapace.ActionMap{ diff --git a/completers/kubeadm_completer/cmd/certs_renew_superAdminConf.go b/completers/kubeadm_completer/cmd/certs_renew_superAdminConf.go new file mode 100644 index 00000000..cc7ad6a2 --- /dev/null +++ b/completers/kubeadm_completer/cmd/certs_renew_superAdminConf.go @@ -0,0 +1,27 @@ +package cmd + +import ( + "github.com/carapace-sh/carapace" + "github.com/spf13/cobra" +) + +var certs_renew_superAdminConfCmd = &cobra.Command{ + Use: "super-admin.conf", + Short: "Renew the certificate embedded in the kubeconfig file for the super-admin", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(certs_renew_superAdminConfCmd).Standalone() + + certs_renew_superAdminConfCmd.Flags().String("cert-dir", "", "The path where to save the certificates") + certs_renew_superAdminConfCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") + certs_renew_superAdminConfCmd.Flags().String("kubeconfig", "", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") + certs_renewCmd.AddCommand(certs_renew_superAdminConfCmd) + + carapace.Gen(certs_renew_superAdminConfCmd).FlagCompletion(carapace.ActionMap{ + "cert-dir": carapace.ActionDirectories(), + "config": carapace.ActionFiles(), + "kubeconfig": carapace.ActionFiles(), + }) +} diff --git a/completers/kubeadm_completer/cmd/completion.go b/completers/kubeadm_completer/cmd/completion.go index d2011ef9..b1613fe0 100644 --- a/completers/kubeadm_completer/cmd/completion.go +++ b/completers/kubeadm_completer/cmd/completion.go @@ -6,13 +6,14 @@ import ( ) var completionCmd = &cobra.Command{ - Use: "completion", + Use: "completion SHELL", Short: "Output shell completion code for the specified shell (bash or zsh)", Run: func(cmd *cobra.Command, args []string) {}, } func init() { carapace.Gen(completionCmd).Standalone() + rootCmd.AddCommand(completionCmd) carapace.Gen(completionCmd).PositionalCompletion( diff --git a/completers/kubeadm_completer/cmd/config.go b/completers/kubeadm_completer/cmd/config.go index dc9c0f4e..8cd6af7f 100644 --- a/completers/kubeadm_completer/cmd/config.go +++ b/completers/kubeadm_completer/cmd/config.go @@ -13,7 +13,8 @@ var configCmd = &cobra.Command{ func init() { carapace.Gen(configCmd).Standalone() - configCmd.PersistentFlags().String("kubeconfig", "~/.kube/config", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") + + configCmd.PersistentFlags().String("kubeconfig", "", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") rootCmd.AddCommand(configCmd) carapace.Gen(configCmd).FlagCompletion(carapace.ActionMap{ diff --git a/completers/kubeadm_completer/cmd/config_images.go b/completers/kubeadm_completer/cmd/config_images.go index ab758a8c..63afa13c 100644 --- a/completers/kubeadm_completer/cmd/config_images.go +++ b/completers/kubeadm_completer/cmd/config_images.go @@ -13,5 +13,6 @@ var config_imagesCmd = &cobra.Command{ func init() { carapace.Gen(config_imagesCmd).Standalone() + configCmd.AddCommand(config_imagesCmd) } diff --git a/completers/kubeadm_completer/cmd/config_images_list.go b/completers/kubeadm_completer/cmd/config_images_list.go index 9eaa370e..07cd4cba 100644 --- a/completers/kubeadm_completer/cmd/config_images_list.go +++ b/completers/kubeadm_completer/cmd/config_images_list.go @@ -2,6 +2,7 @@ package cmd import ( "github.com/carapace-sh/carapace" + "github.com/carapace-sh/carapace-bin/pkg/actions/tools/kubeadm" "github.com/spf13/cobra" ) @@ -13,18 +14,20 @@ var config_images_listCmd = &cobra.Command{ func init() { carapace.Gen(config_images_listCmd).Standalone() - config_images_listCmd.Flags().Bool("allow-missing-template-keys", true, "If true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats.") + + config_images_listCmd.Flags().Bool("allow-missing-template-keys", false, "If true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats.") config_images_listCmd.PersistentFlags().String("config", "", "Path to a kubeadm configuration file.") - config_images_listCmd.Flags().StringP("experimental-output", "o", "text", "Output format.") - config_images_listCmd.PersistentFlags().String("feature-gates", "", "A set of key=value pairs that describe feature gates for various features.") - config_images_listCmd.PersistentFlags().String("image-repository", "k8s.gcr.io", "Choose a container registry to pull control plane images from") - config_images_listCmd.PersistentFlags().String("kubernetes-version", "stable-1", "Choose a specific Kubernetes version for the control plane.") + config_images_listCmd.PersistentFlags().String("feature-gates", "", "A set of key=value pairs that describe feature gates for various features. Options are:") + config_images_listCmd.PersistentFlags().String("image-repository", "", "Choose a container registry to pull control plane images from") + config_images_listCmd.PersistentFlags().String("kubernetes-version", "", "Choose a specific Kubernetes version for the control plane.") + config_images_listCmd.Flags().StringP("output", "o", "", "Output format. One of: text|json|yaml|go-template|go-template-file|template|templatefile|jsonpath|jsonpath-as-json|jsonpath-file.") config_images_listCmd.Flags().Bool("show-managed-fields", false, "If true, keep the managedFields when printing objects in JSON or YAML format.") config_imagesCmd.AddCommand(config_images_listCmd) // TODO feature-gates carapace.Gen(config_images_listCmd).FlagCompletion(carapace.ActionMap{ - "config": carapace.ActionFiles(), - "experimental-output": carapace.ActionValues("text", "json", "yaml", "go-template", "go-template-file", "template", "templatefile", "jsonpath", "jsonpath-as-json", "jsonpath-file"), + "config": carapace.ActionFiles(), + "feature-gates": kubeadm.ActionFeatureGates(), + "output": kubeadm.ActionOutputFormats(), }) } diff --git a/completers/kubeadm_completer/cmd/config_images_pull.go b/completers/kubeadm_completer/cmd/config_images_pull.go index 46e5817b..1e018aae 100644 --- a/completers/kubeadm_completer/cmd/config_images_pull.go +++ b/completers/kubeadm_completer/cmd/config_images_pull.go @@ -2,6 +2,7 @@ package cmd import ( "github.com/carapace-sh/carapace" + "github.com/carapace-sh/carapace-bin/pkg/actions/tools/kubeadm" "github.com/spf13/cobra" ) @@ -13,15 +14,17 @@ var config_images_pullCmd = &cobra.Command{ func init() { carapace.Gen(config_images_pullCmd).Standalone() + config_images_pullCmd.PersistentFlags().String("config", "", "Path to a kubeadm configuration file.") config_images_pullCmd.PersistentFlags().String("cri-socket", "", "Path to the CRI socket to connect. If empty kubeadm will try to auto-detect this value; use this option only if you have more than one CRI installed or if you have non-standard CRI socket.") - config_images_pullCmd.PersistentFlags().String("feature-gates", "", "A set of key=value pairs that describe feature gates for various features.") - config_images_pullCmd.PersistentFlags().String("image-repository", "k8s.gcr.io", "Choose a container registry to pull control plane images from") - config_images_pullCmd.PersistentFlags().String("kubernetes-version", "stable-1", "Choose a specific Kubernetes version for the control plane.") + config_images_pullCmd.PersistentFlags().String("feature-gates", "", "A set of key=value pairs that describe feature gates for various features. Options are:") + config_images_pullCmd.PersistentFlags().String("image-repository", "", "Choose a container registry to pull control plane images from") + config_images_pullCmd.PersistentFlags().String("kubernetes-version", "", "Choose a specific Kubernetes version for the control plane.") config_imagesCmd.AddCommand(config_images_pullCmd) carapace.Gen(config_images_pullCmd).FlagCompletion(carapace.ActionMap{ - "config": carapace.ActionFiles(), - "cri-socket": carapace.ActionFiles(), + "config": carapace.ActionFiles(), + "cri-socket": carapace.ActionFiles(), + "feature-gates": kubeadm.ActionFeatureGates(), }) } diff --git a/completers/kubeadm_completer/cmd/config_print.go b/completers/kubeadm_completer/cmd/config_print.go index c31a352c..150661dd 100644 --- a/completers/kubeadm_completer/cmd/config_print.go +++ b/completers/kubeadm_completer/cmd/config_print.go @@ -13,5 +13,6 @@ var config_printCmd = &cobra.Command{ func init() { carapace.Gen(config_printCmd).Standalone() + configCmd.AddCommand(config_printCmd) } diff --git a/completers/kubeadm_completer/cmd/config_print_initDefaults.go b/completers/kubeadm_completer/cmd/config_print_initDefaults.go index 7db6af9a..f7c1eda7 100644 --- a/completers/kubeadm_completer/cmd/config_print_initDefaults.go +++ b/completers/kubeadm_completer/cmd/config_print_initDefaults.go @@ -13,7 +13,8 @@ var config_print_initDefaultsCmd = &cobra.Command{ func init() { carapace.Gen(config_print_initDefaultsCmd).Standalone() - config_print_initDefaultsCmd.Flags().StringSlice("component-configs", []string{}, "A comma-separated list for component config API objects to print the default values for.") + + config_print_initDefaultsCmd.Flags().StringSlice("component-configs", []string{}, "A comma-separated list for component config API objects to print the default values for. Available values: [KubeProxyConfiguration KubeletConfiguration]. If this flag is not set, no component configs will be printed.") config_printCmd.AddCommand(config_print_initDefaultsCmd) carapace.Gen(config_print_initDefaultsCmd).FlagCompletion(carapace.ActionMap{ diff --git a/completers/kubeadm_completer/cmd/config_print_joinDefaults.go b/completers/kubeadm_completer/cmd/config_print_joinDefaults.go index 8a38d992..fa378ce8 100644 --- a/completers/kubeadm_completer/cmd/config_print_joinDefaults.go +++ b/completers/kubeadm_completer/cmd/config_print_joinDefaults.go @@ -13,10 +13,6 @@ var config_print_joinDefaultsCmd = &cobra.Command{ func init() { carapace.Gen(config_print_joinDefaultsCmd).Standalone() - config_print_joinDefaultsCmd.Flags().StringSlice("component-configs", []string{}, "A comma-separated list for component config API objects to print the default values for. Available values: [KubeProxyConfiguration KubeletConfiguration]. If this flag is not set, no component configs will be printed.") - config_printCmd.AddCommand(config_print_joinDefaultsCmd) - carapace.Gen(config_print_joinDefaultsCmd).FlagCompletion(carapace.ActionMap{ - "component-configs": carapace.ActionValues("KubeProxyConfiguration", "KubeletConfiguration").UniqueList(","), - }) + config_printCmd.AddCommand(config_print_joinDefaultsCmd) } diff --git a/completers/kubeadm_completer/cmd/config_print_resetDefaults.go b/completers/kubeadm_completer/cmd/config_print_resetDefaults.go new file mode 100644 index 00000000..44a68a9a --- /dev/null +++ b/completers/kubeadm_completer/cmd/config_print_resetDefaults.go @@ -0,0 +1,18 @@ +package cmd + +import ( + "github.com/carapace-sh/carapace" + "github.com/spf13/cobra" +) + +var config_print_resetDefaultsCmd = &cobra.Command{ + Use: "reset-defaults", + Short: "Print default reset configuration, that can be used for 'kubeadm reset'", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(config_print_resetDefaultsCmd).Standalone() + + config_printCmd.AddCommand(config_print_resetDefaultsCmd) +} diff --git a/completers/kubeadm_completer/cmd/config_print_upgradeDefaults.go b/completers/kubeadm_completer/cmd/config_print_upgradeDefaults.go new file mode 100644 index 00000000..b4e133cf --- /dev/null +++ b/completers/kubeadm_completer/cmd/config_print_upgradeDefaults.go @@ -0,0 +1,18 @@ +package cmd + +import ( + "github.com/carapace-sh/carapace" + "github.com/spf13/cobra" +) + +var config_print_upgradeDefaultsCmd = &cobra.Command{ + Use: "upgrade-defaults", + Short: "Print default upgrade configuration, that can be used for 'kubeadm upgrade'", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(config_print_upgradeDefaultsCmd).Standalone() + + config_printCmd.AddCommand(config_print_upgradeDefaultsCmd) +} diff --git a/completers/kubeadm_completer/cmd/config_validate.go b/completers/kubeadm_completer/cmd/config_validate.go new file mode 100644 index 00000000..c04cf4b1 --- /dev/null +++ b/completers/kubeadm_completer/cmd/config_validate.go @@ -0,0 +1,24 @@ +package cmd + +import ( + "github.com/carapace-sh/carapace" + "github.com/spf13/cobra" +) + +var config_validateCmd = &cobra.Command{ + Use: "validate", + Short: "Read a file containing the kubeadm configuration API and report any validation problems", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(config_validateCmd).Standalone() + + config_validateCmd.Flags().Bool("allow-experimental-api", false, "Allow validation of experimental, unreleased APIs.") + config_validateCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") + configCmd.AddCommand(config_validateCmd) + + carapace.Gen(config_validateCmd).FlagCompletion(carapace.ActionMap{ + "config": carapace.ActionFiles(), + }) +} diff --git a/completers/kubeadm_completer/cmd/help.go b/completers/kubeadm_completer/cmd/help.go new file mode 100644 index 00000000..12ec8f35 --- /dev/null +++ b/completers/kubeadm_completer/cmd/help.go @@ -0,0 +1,18 @@ +package cmd + +import ( + "github.com/carapace-sh/carapace" + "github.com/spf13/cobra" +) + +var helpCmd = &cobra.Command{ + Use: "help [command]", + Short: "Help about any command", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(helpCmd).Standalone() + + rootCmd.AddCommand(helpCmd) +} diff --git a/completers/kubeadm_completer/cmd/init.go b/completers/kubeadm_completer/cmd/init.go index fdc0861e..beafaef6 100644 --- a/completers/kubeadm_completer/cmd/init.go +++ b/completers/kubeadm_completer/cmd/init.go @@ -3,6 +3,8 @@ package cmd import ( "github.com/carapace-sh/carapace" "github.com/carapace-sh/carapace-bin/completers/kubeadm_completer/cmd/action" + "github.com/carapace-sh/carapace-bin/pkg/actions/net" + "github.com/carapace-sh/carapace-bin/pkg/actions/tools/kubeadm" "github.com/spf13/cobra" ) @@ -14,37 +16,40 @@ var initCmd = &cobra.Command{ func init() { carapace.Gen(initCmd).Standalone() + initCmd.Flags().String("apiserver-advertise-address", "", "The IP address the API Server will advertise it's listening on. If not set the default network interface will be used.") - initCmd.Flags().Int32("apiserver-bind-port", 6443, "Port for the API Server to bind to.") + initCmd.Flags().String("apiserver-bind-port", "", "Port for the API Server to bind to.") initCmd.Flags().StringSlice("apiserver-cert-extra-sans", []string{}, "Optional extra Subject Alternative Names (SANs) to use for the API Server serving certificate. Can be both IP addresses and DNS names.") - initCmd.Flags().String("cert-dir", "/etc/kubernetes/pki", "The path where to save and store the certificates.") - initCmd.Flags().String("certificate-key", "", "Key used to encrypt the control-plane certificates in the kubeadm-certs Secret.") + initCmd.Flags().String("cert-dir", "", "The path where to save and store the certificates.") + initCmd.Flags().String("certificate-key", "", "Key used to encrypt the control-plane certificates in the kubeadm-certs Secret. The certificate key is a hex encoded string that is an AES key of size 32 bytes.") initCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") initCmd.Flags().String("control-plane-endpoint", "", "Specify a stable IP address or DNS name for the control plane.") initCmd.Flags().String("cri-socket", "", "Path to the CRI socket to connect. If empty kubeadm will try to auto-detect this value; use this option only if you have more than one CRI installed or if you have non-standard CRI socket.") initCmd.Flags().Bool("dry-run", false, "Don't apply any changes; just output what would be done.") - initCmd.Flags().String("feature-gates", "", "A set of key=value pairs that describe feature gates for various features.") + initCmd.Flags().String("feature-gates", "", "A set of key=value pairs that describe feature gates for various features. Options are:") initCmd.Flags().StringSlice("ignore-preflight-errors", []string{}, "A list of checks whose errors will be shown as warnings. Example: 'IsPrivilegedUser,Swap'. Value 'all' ignores errors from all checks.") - initCmd.Flags().String("image-repository", "k8s.gcr.io", "Choose a container registry to pull control plane images from") - initCmd.Flags().String("kubernetes-version", "stable-1", "Choose a specific Kubernetes version for the control plane.") + initCmd.Flags().String("image-repository", "", "Choose a container registry to pull control plane images from") + initCmd.Flags().String("kubernetes-version", "", "Choose a specific Kubernetes version for the control plane.") initCmd.Flags().String("node-name", "", "Specify the node name.") - initCmd.Flags().String("patches", "", "Path to a directory that contains files named \"target[suffix][+patchtype].extension\".") - initCmd.Flags().String("pod-network-cidr", "", "Specify range of IP addresses for the pod network.") - initCmd.Flags().String("service-cidr", "10.96.0.0/12", "Use alternative range of IP address for service VIPs.") - initCmd.Flags().String("service-dns-domain", "cluster.local", "Use alternative domain for services, e.g. \"myorg.internal\".") + initCmd.Flags().String("patches", "", "Path to a directory that contains files named \"target[suffix][+patchtype].extension\". For example, \"kube-apiserver0+merge.yaml\" or just \"etcd.json\". \"target\" can be one of \"kube-apiserver\", \"kube-controller-manager\", \"kube-scheduler\", \"etcd\", \"kubeletconfiguration\", \"corednsdeployment\". \"patchtype\" can be one of \"strategic\", \"merge\" or \"json\" and they match the patch formats supported by kubectl. The default \"patchtype\" is \"strategic\". \"extension\" must be either \"json\" or \"yaml\". \"suffix\" is an optional string that can be used to determine which patches are applied first alpha-numerically.") + initCmd.Flags().String("pod-network-cidr", "", "Specify range of IP addresses for the pod network. If set, the control plane will automatically allocate CIDRs for every node.") + initCmd.Flags().String("service-cidr", "", "Use alternative range of IP address for service VIPs.") + initCmd.Flags().String("service-dns-domain", "", "Use alternative domain for services, e.g. \"myorg.internal\".") initCmd.Flags().Bool("skip-certificate-key-print", false, "Don't print the key used to encrypt the control-plane certificates.") initCmd.Flags().StringSlice("skip-phases", []string{}, "List of phases to be skipped") initCmd.Flags().Bool("skip-token-print", false, "Skip printing of the default bootstrap token generated by 'kubeadm init'.") - initCmd.Flags().String("token", "", "The token to use for establishing bidirectional trust between nodes and control-plane nodes.") + initCmd.Flags().String("token", "", "The token to use for establishing bidirectional trust between nodes and control-plane nodes. The format is [a-z0-9]{6}\\.[a-z0-9]{16} - e.g. abcdef.0123456789abcdef") initCmd.Flags().String("token-ttl", "", "The duration before the token is automatically deleted (e.g. 1s, 2m, 3h). If set to '0', the token will never expire") initCmd.Flags().Bool("upload-certs", false, "Upload control-plane certificates to the kubeadm-certs Secret.") rootCmd.AddCommand(initCmd) carapace.Gen(initCmd).FlagCompletion(carapace.ActionMap{ + "apiserver-bind-port": net.ActionPorts(), "cert-dir": carapace.ActionDirectories(), "certificate-key": carapace.ActionFiles(), "config": carapace.ActionFiles(), "cri-socket": carapace.ActionFiles(), + "feature-gates": kubeadm.ActionFeatureGates(), "ignore-preflight-errors": action.ActionChecks().UniqueList(","), "patches": carapace.ActionDirectories(), "skip-phases": carapace.ActionMultiParts(",", func(c carapace.Context) carapace.Action { diff --git a/completers/kubeadm_completer/cmd/init_phase.go b/completers/kubeadm_completer/cmd/init_phase.go index 02c5dbed..9e86f364 100644 --- a/completers/kubeadm_completer/cmd/init_phase.go +++ b/completers/kubeadm_completer/cmd/init_phase.go @@ -7,11 +7,12 @@ import ( var init_phaseCmd = &cobra.Command{ Use: "phase", - Short: "Use this command to invoke single phase of the init workflow", + Short: "Use this command to invoke single phase of the \"init\" workflow", Run: func(cmd *cobra.Command, args []string) {}, } func init() { carapace.Gen(init_phaseCmd).Standalone() + initCmd.AddCommand(init_phaseCmd) } diff --git a/completers/kubeadm_completer/cmd/init_phase_addon.go b/completers/kubeadm_completer/cmd/init_phase_addon.go index 39e67896..f0b0816f 100644 --- a/completers/kubeadm_completer/cmd/init_phase_addon.go +++ b/completers/kubeadm_completer/cmd/init_phase_addon.go @@ -13,5 +13,6 @@ var init_phase_addonCmd = &cobra.Command{ func init() { carapace.Gen(init_phase_addonCmd).Standalone() + init_phaseCmd.AddCommand(init_phase_addonCmd) } diff --git a/completers/kubeadm_completer/cmd/init_phase_addon_all.go b/completers/kubeadm_completer/cmd/init_phase_addon_all.go index 6714f4af..d985088c 100644 --- a/completers/kubeadm_completer/cmd/init_phase_addon_all.go +++ b/completers/kubeadm_completer/cmd/init_phase_addon_all.go @@ -2,6 +2,8 @@ package cmd import ( "github.com/carapace-sh/carapace" + "github.com/carapace-sh/carapace-bin/pkg/actions/net" + "github.com/carapace-sh/carapace-bin/pkg/actions/tools/kubeadm" "github.com/spf13/cobra" ) @@ -13,21 +15,25 @@ var init_phase_addon_allCmd = &cobra.Command{ func init() { carapace.Gen(init_phase_addon_allCmd).Standalone() + init_phase_addon_allCmd.Flags().String("apiserver-advertise-address", "", "The IP address the API Server will advertise it's listening on. If not set the default network interface will be used.") - init_phase_addon_allCmd.Flags().Int32("apiserver-bind-port", 6443, "Port for the API Server to bind to.") + init_phase_addon_allCmd.Flags().String("apiserver-bind-port", "", "Port for the API Server to bind to.") init_phase_addon_allCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") init_phase_addon_allCmd.Flags().String("control-plane-endpoint", "", "Specify a stable IP address or DNS name for the control plane.") - init_phase_addon_allCmd.Flags().String("feature-gates", "", "A set of key=value pairs that describe feature gates for various features.") - init_phase_addon_allCmd.Flags().String("image-repository", "k8s.gcr.io", "Choose a container registry to pull control plane images from") - init_phase_addon_allCmd.Flags().String("kubeconfig", "/etc/kubernetes/admin.conf", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") - init_phase_addon_allCmd.Flags().String("kubernetes-version", "stable-1", "Choose a specific Kubernetes version for the control plane.") + init_phase_addon_allCmd.Flags().Bool("dry-run", false, "Don't apply any changes; just output what would be done.") + init_phase_addon_allCmd.Flags().String("feature-gates", "", "A set of key=value pairs that describe feature gates for various features. Options are:") + init_phase_addon_allCmd.Flags().String("image-repository", "", "Choose a container registry to pull control plane images from") + init_phase_addon_allCmd.Flags().String("kubeconfig", "", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") + init_phase_addon_allCmd.Flags().String("kubernetes-version", "", "Choose a specific Kubernetes version for the control plane.") init_phase_addon_allCmd.Flags().String("pod-network-cidr", "", "Specify range of IP addresses for the pod network. If set, the control plane will automatically allocate CIDRs for every node.") - init_phase_addon_allCmd.Flags().String("service-cidr", "10.96.0.0/12", "Use alternative range of IP address for service VIPs.") - init_phase_addon_allCmd.Flags().String("service-dns-domain", "cluster.local", "Use alternative domain for services, e.g. \"myorg.internal\".") + init_phase_addon_allCmd.Flags().String("service-cidr", "", "Use alternative range of IP address for service VIPs.") + init_phase_addon_allCmd.Flags().String("service-dns-domain", "", "Use alternative domain for services, e.g. \"myorg.internal\".") init_phase_addonCmd.AddCommand(init_phase_addon_allCmd) carapace.Gen(init_phase_addon_allCmd).FlagCompletion(carapace.ActionMap{ - "config": carapace.ActionFiles(), - "kubeconfig": carapace.ActionFiles(), + "apiserver-bind-port": net.ActionPorts(), + "config": carapace.ActionFiles(), + "feature-gates": kubeadm.ActionFeatureGates(), + "kubeconfig": carapace.ActionFiles(), }) } diff --git a/completers/kubeadm_completer/cmd/init_phase_addon_coredns.go b/completers/kubeadm_completer/cmd/init_phase_addon_coredns.go index e4fd5b19..06b830aa 100644 --- a/completers/kubeadm_completer/cmd/init_phase_addon_coredns.go +++ b/completers/kubeadm_completer/cmd/init_phase_addon_coredns.go @@ -2,6 +2,7 @@ package cmd import ( "github.com/carapace-sh/carapace" + "github.com/carapace-sh/carapace-bin/pkg/actions/tools/kubeadm" "github.com/spf13/cobra" ) @@ -13,12 +14,21 @@ var init_phase_addon_corednsCmd = &cobra.Command{ func init() { carapace.Gen(init_phase_addon_corednsCmd).Standalone() + init_phase_addon_corednsCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") - init_phase_addon_corednsCmd.Flags().String("feature-gates", "", "A set of key=value pairs that describe feature gates for various features.") - init_phase_addon_corednsCmd.Flags().String("image-repository", "k8s.gcr.io", "Choose a container registry to pull control plane images from") - init_phase_addon_corednsCmd.Flags().String("kubeconfig", "/etc/kubernetes/admin.conf", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") - init_phase_addon_corednsCmd.Flags().String("kubernetes-version", "stable-1", "Choose a specific Kubernetes version for the control plane.") - init_phase_addon_corednsCmd.Flags().String("service-cidr", "10.96.0.0/12", "Use alternative range of IP address for service VIPs.") - init_phase_addon_corednsCmd.Flags().String("service-dns-domain", "cluster.local", "Use alternative domain for services, e.g. \"myorg.internal\".") + init_phase_addon_corednsCmd.Flags().Bool("dry-run", false, "Don't apply any changes; just output what would be done.") + init_phase_addon_corednsCmd.Flags().String("feature-gates", "", "A set of key=value pairs that describe feature gates for various features. Options are:") + init_phase_addon_corednsCmd.Flags().String("image-repository", "", "Choose a container registry to pull control plane images from") + init_phase_addon_corednsCmd.Flags().String("kubeconfig", "", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") + init_phase_addon_corednsCmd.Flags().String("kubernetes-version", "", "Choose a specific Kubernetes version for the control plane.") + init_phase_addon_corednsCmd.Flags().Bool("print-manifest", false, "Print the addon manifests to STDOUT instead of installing them") + init_phase_addon_corednsCmd.Flags().String("service-cidr", "", "Use alternative range of IP address for service VIPs.") + init_phase_addon_corednsCmd.Flags().String("service-dns-domain", "", "Use alternative domain for services, e.g. \"myorg.internal\".") init_phase_addonCmd.AddCommand(init_phase_addon_corednsCmd) + + carapace.Gen(init_phase_addon_corednsCmd).FlagCompletion(carapace.ActionMap{ + "config": carapace.ActionFiles(), + "feature-gates": kubeadm.ActionFeatureGates(), + "kubeconfig": carapace.ActionFiles(), + }) } diff --git a/completers/kubeadm_completer/cmd/init_phase_addon_kubeProxy.go b/completers/kubeadm_completer/cmd/init_phase_addon_kubeProxy.go index b0726904..5f79bfdf 100644 --- a/completers/kubeadm_completer/cmd/init_phase_addon_kubeProxy.go +++ b/completers/kubeadm_completer/cmd/init_phase_addon_kubeProxy.go @@ -2,6 +2,7 @@ package cmd import ( "github.com/carapace-sh/carapace" + "github.com/carapace-sh/carapace-bin/pkg/actions/net" "github.com/spf13/cobra" ) @@ -13,18 +14,22 @@ var init_phase_addon_kubeProxyCmd = &cobra.Command{ func init() { carapace.Gen(init_phase_addon_kubeProxyCmd).Standalone() + init_phase_addon_kubeProxyCmd.Flags().String("apiserver-advertise-address", "", "The IP address the API Server will advertise it's listening on. If not set the default network interface will be used.") - init_phase_addon_kubeProxyCmd.Flags().Int32("apiserver-bind-port", 6443, "Port for the API Server to bind to.") + init_phase_addon_kubeProxyCmd.Flags().String("apiserver-bind-port", "", "Port for the API Server to bind to.") init_phase_addon_kubeProxyCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") init_phase_addon_kubeProxyCmd.Flags().String("control-plane-endpoint", "", "Specify a stable IP address or DNS name for the control plane.") - init_phase_addon_kubeProxyCmd.Flags().String("image-repository", "k8s.gcr.io", "Choose a container registry to pull control plane images from") - init_phase_addon_kubeProxyCmd.Flags().String("kubeconfig", "/etc/kubernetes/admin.conf", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") - init_phase_addon_kubeProxyCmd.Flags().String("kubernetes-version", "stable-1", "Choose a specific Kubernetes version for the control plane.") + init_phase_addon_kubeProxyCmd.Flags().Bool("dry-run", false, "Don't apply any changes; just output what would be done.") + init_phase_addon_kubeProxyCmd.Flags().String("image-repository", "", "Choose a container registry to pull control plane images from") + init_phase_addon_kubeProxyCmd.Flags().String("kubeconfig", "", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") + init_phase_addon_kubeProxyCmd.Flags().String("kubernetes-version", "", "Choose a specific Kubernetes version for the control plane.") init_phase_addon_kubeProxyCmd.Flags().String("pod-network-cidr", "", "Specify range of IP addresses for the pod network. If set, the control plane will automatically allocate CIDRs for every node.") + init_phase_addon_kubeProxyCmd.Flags().Bool("print-manifest", false, "Print the addon manifests to STDOUT instead of installing them") init_phase_addonCmd.AddCommand(init_phase_addon_kubeProxyCmd) carapace.Gen(init_phase_addon_kubeProxyCmd).FlagCompletion(carapace.ActionMap{ - "config": carapace.ActionFiles(), - "kubeconfig": carapace.ActionFiles(), + "apiserver-bind-port": net.ActionPorts(), + "config": carapace.ActionFiles(), + "kubeconfig": carapace.ActionFiles(), }) } diff --git a/completers/kubeadm_completer/cmd/init_phase_bootstrapToken.go b/completers/kubeadm_completer/cmd/init_phase_bootstrapToken.go index 7668de9f..1000dd29 100644 --- a/completers/kubeadm_completer/cmd/init_phase_bootstrapToken.go +++ b/completers/kubeadm_completer/cmd/init_phase_bootstrapToken.go @@ -6,15 +6,18 @@ import ( ) var init_phase_bootstrapTokenCmd = &cobra.Command{ - Use: "bootstrap-token", - Short: "Generates bootstrap tokens used to join a node to a cluster", - Run: func(cmd *cobra.Command, args []string) {}, + Use: "bootstrap-token", + Short: "Generates bootstrap tokens used to join a node to a cluster", + Aliases: []string{"bootstraptoken"}, + Run: func(cmd *cobra.Command, args []string) {}, } func init() { carapace.Gen(init_phase_bootstrapTokenCmd).Standalone() + init_phase_bootstrapTokenCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") - init_phase_bootstrapTokenCmd.Flags().String("kubeconfig", "/etc/kubernetes/admin.conf", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") + init_phase_bootstrapTokenCmd.Flags().Bool("dry-run", false, "Don't apply any changes; just output what would be done.") + init_phase_bootstrapTokenCmd.Flags().String("kubeconfig", "", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") init_phase_bootstrapTokenCmd.Flags().Bool("skip-token-print", false, "Skip printing of the default bootstrap token generated by 'kubeadm init'.") init_phaseCmd.AddCommand(init_phase_bootstrapTokenCmd) diff --git a/completers/kubeadm_completer/cmd/init_phase_certs.go b/completers/kubeadm_completer/cmd/init_phase_certs.go index 3988b6ba..aa22ae56 100644 --- a/completers/kubeadm_completer/cmd/init_phase_certs.go +++ b/completers/kubeadm_completer/cmd/init_phase_certs.go @@ -13,5 +13,6 @@ var init_phase_certsCmd = &cobra.Command{ func init() { carapace.Gen(init_phase_certsCmd).Standalone() + init_phaseCmd.AddCommand(init_phase_certsCmd) } diff --git a/completers/kubeadm_completer/cmd/init_phase_certs_all.go b/completers/kubeadm_completer/cmd/init_phase_certs_all.go index 7ebc8072..c994b22c 100644 --- a/completers/kubeadm_completer/cmd/init_phase_certs_all.go +++ b/completers/kubeadm_completer/cmd/init_phase_certs_all.go @@ -13,14 +13,16 @@ var init_phase_certs_allCmd = &cobra.Command{ func init() { carapace.Gen(init_phase_certs_allCmd).Standalone() + init_phase_certs_allCmd.Flags().String("apiserver-advertise-address", "", "The IP address the API Server will advertise it's listening on. If not set the default network interface will be used.") init_phase_certs_allCmd.Flags().StringSlice("apiserver-cert-extra-sans", []string{}, "Optional extra Subject Alternative Names (SANs) to use for the API Server serving certificate. Can be both IP addresses and DNS names.") - init_phase_certs_allCmd.Flags().String("cert-dir", "/etc/kubernetes/pki", "The path where to save and store the certificates.") + init_phase_certs_allCmd.Flags().String("cert-dir", "", "The path where to save and store the certificates.") init_phase_certs_allCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") init_phase_certs_allCmd.Flags().String("control-plane-endpoint", "", "Specify a stable IP address or DNS name for the control plane.") - init_phase_certs_allCmd.Flags().String("kubernetes-version", "stable-1", "Choose a specific Kubernetes version for the control plane.") - init_phase_certs_allCmd.Flags().String("service-cidr", "10.96.0.0/12", "Use alternative range of IP address for service VIPs.") - init_phase_certs_allCmd.Flags().String("service-dns-domain", "cluster.local", "Use alternative domain for services, e.g. \"myorg.internal\".") + init_phase_certs_allCmd.Flags().Bool("dry-run", false, "Don't apply any changes; just output what would be done.") + init_phase_certs_allCmd.Flags().String("kubernetes-version", "", "Choose a specific Kubernetes version for the control plane.") + init_phase_certs_allCmd.Flags().String("service-cidr", "", "Use alternative range of IP address for service VIPs.") + init_phase_certs_allCmd.Flags().String("service-dns-domain", "", "Use alternative domain for services, e.g. \"myorg.internal\".") init_phase_certsCmd.AddCommand(init_phase_certs_allCmd) carapace.Gen(init_phase_certs_allCmd).FlagCompletion(carapace.ActionMap{ diff --git a/completers/kubeadm_completer/cmd/init_phase_certs_apiserver.go b/completers/kubeadm_completer/cmd/init_phase_certs_apiserver.go index 881a930d..75908a22 100644 --- a/completers/kubeadm_completer/cmd/init_phase_certs_apiserver.go +++ b/completers/kubeadm_completer/cmd/init_phase_certs_apiserver.go @@ -13,14 +13,16 @@ var init_phase_certs_apiserverCmd = &cobra.Command{ func init() { carapace.Gen(init_phase_certs_apiserverCmd).Standalone() + init_phase_certs_apiserverCmd.Flags().String("apiserver-advertise-address", "", "The IP address the API Server will advertise it's listening on. If not set the default network interface will be used.") init_phase_certs_apiserverCmd.Flags().StringSlice("apiserver-cert-extra-sans", []string{}, "Optional extra Subject Alternative Names (SANs) to use for the API Server serving certificate. Can be both IP addresses and DNS names.") - init_phase_certs_apiserverCmd.Flags().String("cert-dir", "/etc/kubernetes/pki", "The path where to save and store the certificates.") + init_phase_certs_apiserverCmd.Flags().String("cert-dir", "", "The path where to save and store the certificates.") init_phase_certs_apiserverCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") init_phase_certs_apiserverCmd.Flags().String("control-plane-endpoint", "", "Specify a stable IP address or DNS name for the control plane.") - init_phase_certs_apiserverCmd.Flags().String("kubernetes-version", "stable-1", "Choose a specific Kubernetes version for the control plane.") - init_phase_certs_apiserverCmd.Flags().String("service-cidr", "10.96.0.0/12", "Use alternative range of IP address for service VIPs.") - init_phase_certs_apiserverCmd.Flags().String("service-dns-domain", "cluster.local", "Use alternative domain for services, e.g. \"myorg.internal\".") + init_phase_certs_apiserverCmd.Flags().Bool("dry-run", false, "Don't apply any changes; just output what would be done.") + init_phase_certs_apiserverCmd.Flags().String("kubernetes-version", "", "Choose a specific Kubernetes version for the control plane.") + init_phase_certs_apiserverCmd.Flags().String("service-cidr", "", "Use alternative range of IP address for service VIPs.") + init_phase_certs_apiserverCmd.Flags().String("service-dns-domain", "", "Use alternative domain for services, e.g. \"myorg.internal\".") init_phase_certsCmd.AddCommand(init_phase_certs_apiserverCmd) carapace.Gen(init_phase_certs_apiserverCmd).FlagCompletion(carapace.ActionMap{ diff --git a/completers/kubeadm_completer/cmd/init_phase_certs_apiserverEtcdClient.go b/completers/kubeadm_completer/cmd/init_phase_certs_apiserverEtcdClient.go index 18d66853..b5d36d07 100644 --- a/completers/kubeadm_completer/cmd/init_phase_certs_apiserverEtcdClient.go +++ b/completers/kubeadm_completer/cmd/init_phase_certs_apiserverEtcdClient.go @@ -13,9 +13,11 @@ var init_phase_certs_apiserverEtcdClientCmd = &cobra.Command{ func init() { carapace.Gen(init_phase_certs_apiserverEtcdClientCmd).Standalone() - init_phase_certs_apiserverEtcdClientCmd.Flags().String("cert-dir", "/etc/kubernetes/pki", "The path where to save and store the certificates.") + + init_phase_certs_apiserverEtcdClientCmd.Flags().String("cert-dir", "", "The path where to save and store the certificates.") init_phase_certs_apiserverEtcdClientCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") - init_phase_certs_apiserverEtcdClientCmd.Flags().String("kubernetes-version", "stable-1", "Choose a specific Kubernetes version for the control plane.") + init_phase_certs_apiserverEtcdClientCmd.Flags().Bool("dry-run", false, "Don't apply any changes; just output what would be done.") + init_phase_certs_apiserverEtcdClientCmd.Flags().String("kubernetes-version", "", "Choose a specific Kubernetes version for the control plane.") init_phase_certsCmd.AddCommand(init_phase_certs_apiserverEtcdClientCmd) carapace.Gen(init_phase_certs_apiserverEtcdClientCmd).FlagCompletion(carapace.ActionMap{ diff --git a/completers/kubeadm_completer/cmd/init_phase_certs_apiserverKubeletClient.go b/completers/kubeadm_completer/cmd/init_phase_certs_apiserverKubeletClient.go index ab9d9d69..5b604d37 100644 --- a/completers/kubeadm_completer/cmd/init_phase_certs_apiserverKubeletClient.go +++ b/completers/kubeadm_completer/cmd/init_phase_certs_apiserverKubeletClient.go @@ -13,9 +13,11 @@ var init_phase_certs_apiserverKubeletClientCmd = &cobra.Command{ func init() { carapace.Gen(init_phase_certs_apiserverKubeletClientCmd).Standalone() - init_phase_certs_apiserverKubeletClientCmd.Flags().String("cert-dir", "/etc/kubernetes/pki", "The path where to save and store the certificates.") + + init_phase_certs_apiserverKubeletClientCmd.Flags().String("cert-dir", "", "The path where to save and store the certificates.") init_phase_certs_apiserverKubeletClientCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") - init_phase_certs_apiserverKubeletClientCmd.Flags().String("kubernetes-version", "stable-1", "Choose a specific Kubernetes version for the control plane.") + init_phase_certs_apiserverKubeletClientCmd.Flags().Bool("dry-run", false, "Don't apply any changes; just output what would be done.") + init_phase_certs_apiserverKubeletClientCmd.Flags().String("kubernetes-version", "", "Choose a specific Kubernetes version for the control plane.") init_phase_certsCmd.AddCommand(init_phase_certs_apiserverKubeletClientCmd) carapace.Gen(init_phase_certs_apiserverKubeletClientCmd).FlagCompletion(carapace.ActionMap{ diff --git a/completers/kubeadm_completer/cmd/init_phase_certs_ca.go b/completers/kubeadm_completer/cmd/init_phase_certs_ca.go index 7ab2bfac..aae9bb94 100644 --- a/completers/kubeadm_completer/cmd/init_phase_certs_ca.go +++ b/completers/kubeadm_completer/cmd/init_phase_certs_ca.go @@ -13,9 +13,11 @@ var init_phase_certs_caCmd = &cobra.Command{ func init() { carapace.Gen(init_phase_certs_caCmd).Standalone() - init_phase_certs_caCmd.Flags().String("cert-dir", "/etc/kubernetes/pki", "The path where to save and store the certificates.") + + init_phase_certs_caCmd.Flags().String("cert-dir", "", "The path where to save and store the certificates.") init_phase_certs_caCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") - init_phase_certs_caCmd.Flags().String("kubernetes-version", "stable-1", "Choose a specific Kubernetes version for the control plane.") + init_phase_certs_caCmd.Flags().Bool("dry-run", false, "Don't apply any changes; just output what would be done.") + init_phase_certs_caCmd.Flags().String("kubernetes-version", "", "Choose a specific Kubernetes version for the control plane.") init_phase_certsCmd.AddCommand(init_phase_certs_caCmd) carapace.Gen(init_phase_certs_caCmd).FlagCompletion(carapace.ActionMap{ diff --git a/completers/kubeadm_completer/cmd/init_phase_certs_etcdCa.go b/completers/kubeadm_completer/cmd/init_phase_certs_etcdCa.go index 6e81e17d..e4655cb0 100644 --- a/completers/kubeadm_completer/cmd/init_phase_certs_etcdCa.go +++ b/completers/kubeadm_completer/cmd/init_phase_certs_etcdCa.go @@ -13,9 +13,11 @@ var init_phase_certs_etcdCaCmd = &cobra.Command{ func init() { carapace.Gen(init_phase_certs_etcdCaCmd).Standalone() - init_phase_certs_etcdCaCmd.Flags().String("cert-dir", "/etc/kubernetes/pki", "The path where to save and store the certificates.") + + init_phase_certs_etcdCaCmd.Flags().String("cert-dir", "", "The path where to save and store the certificates.") init_phase_certs_etcdCaCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") - init_phase_certs_etcdCaCmd.Flags().String("kubernetes-version", "stable-1", "Choose a specific Kubernetes version for the control plane.") + init_phase_certs_etcdCaCmd.Flags().Bool("dry-run", false, "Don't apply any changes; just output what would be done.") + init_phase_certs_etcdCaCmd.Flags().String("kubernetes-version", "", "Choose a specific Kubernetes version for the control plane.") init_phase_certsCmd.AddCommand(init_phase_certs_etcdCaCmd) carapace.Gen(init_phase_certs_etcdCaCmd).FlagCompletion(carapace.ActionMap{ diff --git a/completers/kubeadm_completer/cmd/init_phase_certs_etcdHealthcheckClient.go b/completers/kubeadm_completer/cmd/init_phase_certs_etcdHealthcheckClient.go index f7bd3848..9d4f49de 100644 --- a/completers/kubeadm_completer/cmd/init_phase_certs_etcdHealthcheckClient.go +++ b/completers/kubeadm_completer/cmd/init_phase_certs_etcdHealthcheckClient.go @@ -13,9 +13,11 @@ var init_phase_certs_etcdHealthcheckClientCmd = &cobra.Command{ func init() { carapace.Gen(init_phase_certs_etcdHealthcheckClientCmd).Standalone() - init_phase_certs_etcdHealthcheckClientCmd.Flags().String("cert-dir", "/etc/kubernetes/pki", "The path where to save and store the certificates.") + + init_phase_certs_etcdHealthcheckClientCmd.Flags().String("cert-dir", "", "The path where to save and store the certificates.") init_phase_certs_etcdHealthcheckClientCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") - init_phase_certs_etcdHealthcheckClientCmd.Flags().String("kubernetes-version", "stable-1", "Choose a specific Kubernetes version for the control plane.") + init_phase_certs_etcdHealthcheckClientCmd.Flags().Bool("dry-run", false, "Don't apply any changes; just output what would be done.") + init_phase_certs_etcdHealthcheckClientCmd.Flags().String("kubernetes-version", "", "Choose a specific Kubernetes version for the control plane.") init_phase_certsCmd.AddCommand(init_phase_certs_etcdHealthcheckClientCmd) carapace.Gen(init_phase_certs_etcdHealthcheckClientCmd).FlagCompletion(carapace.ActionMap{ diff --git a/completers/kubeadm_completer/cmd/init_phase_certs_etcdPeer.go b/completers/kubeadm_completer/cmd/init_phase_certs_etcdPeer.go index 3dbcdd84..00122de7 100644 --- a/completers/kubeadm_completer/cmd/init_phase_certs_etcdPeer.go +++ b/completers/kubeadm_completer/cmd/init_phase_certs_etcdPeer.go @@ -13,9 +13,11 @@ var init_phase_certs_etcdPeerCmd = &cobra.Command{ func init() { carapace.Gen(init_phase_certs_etcdPeerCmd).Standalone() - init_phase_certs_etcdPeerCmd.Flags().String("cert-dir", "/etc/kubernetes/pki", "The path where to save and store the certificates.") + + init_phase_certs_etcdPeerCmd.Flags().String("cert-dir", "", "The path where to save and store the certificates.") init_phase_certs_etcdPeerCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") - init_phase_certs_etcdPeerCmd.Flags().String("kubernetes-version", "stable-1", "Choose a specific Kubernetes version for the control plane.") + init_phase_certs_etcdPeerCmd.Flags().Bool("dry-run", false, "Don't apply any changes; just output what would be done.") + init_phase_certs_etcdPeerCmd.Flags().String("kubernetes-version", "", "Choose a specific Kubernetes version for the control plane.") init_phase_certsCmd.AddCommand(init_phase_certs_etcdPeerCmd) carapace.Gen(init_phase_certs_etcdPeerCmd).FlagCompletion(carapace.ActionMap{ diff --git a/completers/kubeadm_completer/cmd/init_phase_certs_etcdServer.go b/completers/kubeadm_completer/cmd/init_phase_certs_etcdServer.go index e240d907..8024fffa 100644 --- a/completers/kubeadm_completer/cmd/init_phase_certs_etcdServer.go +++ b/completers/kubeadm_completer/cmd/init_phase_certs_etcdServer.go @@ -13,9 +13,11 @@ var init_phase_certs_etcdServerCmd = &cobra.Command{ func init() { carapace.Gen(init_phase_certs_etcdServerCmd).Standalone() - init_phase_certs_etcdServerCmd.Flags().String("cert-dir", "/etc/kubernetes/pki", "The path where to save and store the certificates.") + + init_phase_certs_etcdServerCmd.Flags().String("cert-dir", "", "The path where to save and store the certificates.") init_phase_certs_etcdServerCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") - init_phase_certs_etcdServerCmd.Flags().String("kubernetes-version", "stable-1", "Choose a specific Kubernetes version for the control plane.") + init_phase_certs_etcdServerCmd.Flags().Bool("dry-run", false, "Don't apply any changes; just output what would be done.") + init_phase_certs_etcdServerCmd.Flags().String("kubernetes-version", "", "Choose a specific Kubernetes version for the control plane.") init_phase_certsCmd.AddCommand(init_phase_certs_etcdServerCmd) carapace.Gen(init_phase_certs_etcdServerCmd).FlagCompletion(carapace.ActionMap{ diff --git a/completers/kubeadm_completer/cmd/init_phase_certs_frontProxyCa.go b/completers/kubeadm_completer/cmd/init_phase_certs_frontProxyCa.go index 3b5db8d2..f1efd843 100644 --- a/completers/kubeadm_completer/cmd/init_phase_certs_frontProxyCa.go +++ b/completers/kubeadm_completer/cmd/init_phase_certs_frontProxyCa.go @@ -13,9 +13,11 @@ var init_phase_certs_frontProxyCaCmd = &cobra.Command{ func init() { carapace.Gen(init_phase_certs_frontProxyCaCmd).Standalone() - init_phase_certs_frontProxyCaCmd.Flags().String("cert-dir", "/etc/kubernetes/pki", "The path where to save and store the certificates.") + + init_phase_certs_frontProxyCaCmd.Flags().String("cert-dir", "", "The path where to save and store the certificates.") init_phase_certs_frontProxyCaCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") - init_phase_certs_frontProxyCaCmd.Flags().String("kubernetes-version", "stable-1", "Choose a specific Kubernetes version for the control plane.") + init_phase_certs_frontProxyCaCmd.Flags().Bool("dry-run", false, "Don't apply any changes; just output what would be done.") + init_phase_certs_frontProxyCaCmd.Flags().String("kubernetes-version", "", "Choose a specific Kubernetes version for the control plane.") init_phase_certsCmd.AddCommand(init_phase_certs_frontProxyCaCmd) carapace.Gen(init_phase_certs_frontProxyCaCmd).FlagCompletion(carapace.ActionMap{ diff --git a/completers/kubeadm_completer/cmd/init_phase_certs_frontProxyClient.go b/completers/kubeadm_completer/cmd/init_phase_certs_frontProxyClient.go index f28731bf..40c418bc 100644 --- a/completers/kubeadm_completer/cmd/init_phase_certs_frontProxyClient.go +++ b/completers/kubeadm_completer/cmd/init_phase_certs_frontProxyClient.go @@ -13,9 +13,11 @@ var init_phase_certs_frontProxyClientCmd = &cobra.Command{ func init() { carapace.Gen(init_phase_certs_frontProxyClientCmd).Standalone() - init_phase_certs_frontProxyClientCmd.Flags().String("cert-dir", "/etc/kubernetes/pki", "The path where to save and store the certificates.") + + init_phase_certs_frontProxyClientCmd.Flags().String("cert-dir", "", "The path where to save and store the certificates.") init_phase_certs_frontProxyClientCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") - init_phase_certs_frontProxyClientCmd.Flags().String("kubernetes-version", "stable-1", "Choose a specific Kubernetes version for the control plane.") + init_phase_certs_frontProxyClientCmd.Flags().Bool("dry-run", false, "Don't apply any changes; just output what would be done.") + init_phase_certs_frontProxyClientCmd.Flags().String("kubernetes-version", "", "Choose a specific Kubernetes version for the control plane.") init_phase_certsCmd.AddCommand(init_phase_certs_frontProxyClientCmd) carapace.Gen(init_phase_certs_frontProxyClientCmd).FlagCompletion(carapace.ActionMap{ diff --git a/completers/kubeadm_completer/cmd/init_phase_certs_sa.go b/completers/kubeadm_completer/cmd/init_phase_certs_sa.go index 110d4028..ea301d6e 100644 --- a/completers/kubeadm_completer/cmd/init_phase_certs_sa.go +++ b/completers/kubeadm_completer/cmd/init_phase_certs_sa.go @@ -13,10 +13,15 @@ var init_phase_certs_saCmd = &cobra.Command{ func init() { carapace.Gen(init_phase_certs_saCmd).Standalone() - init_phase_certs_saCmd.Flags().String("cert-dir", "/etc/kubernetes/pki", "The path where to save and store the certificates.") + + init_phase_certs_saCmd.Flags().String("cert-dir", "", "The path where to save and store the certificates.") + init_phase_certs_saCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") + init_phase_certs_saCmd.Flags().Bool("dry-run", false, "Don't apply any changes; just output what would be done.") + init_phase_certs_saCmd.Flags().String("kubernetes-version", "", "Choose a specific Kubernetes version for the control plane.") init_phase_certsCmd.AddCommand(init_phase_certs_saCmd) carapace.Gen(init_phase_certs_saCmd).FlagCompletion(carapace.ActionMap{ "cert-dir": carapace.ActionDirectories(), + "config": carapace.ActionFiles(), }) } diff --git a/completers/kubeadm_completer/cmd/init_phase_controlPlane_all.go b/completers/kubeadm_completer/cmd/init_phase_controlPlane_all.go index ed5c17b0..7df45b59 100644 --- a/completers/kubeadm_completer/cmd/init_phase_controlPlane_all.go +++ b/completers/kubeadm_completer/cmd/init_phase_controlPlane_all.go @@ -2,6 +2,8 @@ package cmd import ( "github.com/carapace-sh/carapace" + "github.com/carapace-sh/carapace-bin/pkg/actions/net" + "github.com/carapace-sh/carapace-bin/pkg/actions/tools/kubeadm" "github.com/spf13/cobra" ) @@ -13,26 +15,32 @@ var init_phase_controlPlane_allCmd = &cobra.Command{ func init() { carapace.Gen(init_phase_controlPlane_allCmd).Standalone() + init_phase_controlPlane_allCmd.Flags().String("apiserver-advertise-address", "", "The IP address the API Server will advertise it's listening on. If not set the default network interface will be used.") - init_phase_controlPlane_allCmd.Flags().Int32("apiserver-bind-port", 6443, "Port for the API Server to bind to.") + init_phase_controlPlane_allCmd.Flags().String("apiserver-bind-port", "", "Port for the API Server to bind to.") init_phase_controlPlane_allCmd.Flags().String("apiserver-extra-args", "", "A set of extra flags to pass to the API Server or override default ones in form of =") - init_phase_controlPlane_allCmd.Flags().String("cert-dir", "/etc/kubernetes/pki", "The path where to save and store the certificates.") + init_phase_controlPlane_allCmd.Flags().String("cert-dir", "", "The path where to save and store the certificates.") init_phase_controlPlane_allCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") init_phase_controlPlane_allCmd.Flags().String("control-plane-endpoint", "", "Specify a stable IP address or DNS name for the control plane.") init_phase_controlPlane_allCmd.Flags().String("controller-manager-extra-args", "", "A set of extra flags to pass to the Controller Manager or override default ones in form of =") init_phase_controlPlane_allCmd.Flags().Bool("dry-run", false, "Don't apply any changes; just output what would be done.") - init_phase_controlPlane_allCmd.Flags().String("feature-gates", "", "A set of key=value pairs that describe feature gates for various features.") - init_phase_controlPlane_allCmd.Flags().String("image-repository", "k8s.gcr.io", "Choose a container registry to pull control plane images from") - init_phase_controlPlane_allCmd.Flags().String("kubernetes-version", "stable-1", "Choose a specific Kubernetes version for the control plane.") - init_phase_controlPlane_allCmd.Flags().String("patches", "", "Path to a directory that contains files named \"target[suffix][+patchtype].extension\".") + init_phase_controlPlane_allCmd.Flags().String("feature-gates", "", "A set of key=value pairs that describe feature gates for various features. Options are:") + init_phase_controlPlane_allCmd.Flags().String("image-repository", "", "Choose a container registry to pull control plane images from") + init_phase_controlPlane_allCmd.Flags().String("kubernetes-version", "", "Choose a specific Kubernetes version for the control plane.") + init_phase_controlPlane_allCmd.Flags().String("patches", "", "Path to a directory that contains files named \"target[suffix][+patchtype].extension\". For example, \"kube-apiserver0+merge.yaml\" or just \"etcd.json\". \"target\" can be one of \"kube-apiserver\", \"kube-controller-manager\", \"kube-scheduler\", \"etcd\", \"kubeletconfiguration\", \"corednsdeployment\". \"patchtype\" can be one of \"strategic\", \"merge\" or \"json\" and they match the patch formats supported by kubectl. The default \"patchtype\" is \"strategic\". \"extension\" must be either \"json\" or \"yaml\". \"suffix\" is an optional string that can be used to determine which patches are applied first alpha-numerically.") init_phase_controlPlane_allCmd.Flags().String("pod-network-cidr", "", "Specify range of IP addresses for the pod network. If set, the control plane will automatically allocate CIDRs for every node.") init_phase_controlPlane_allCmd.Flags().String("scheduler-extra-args", "", "A set of extra flags to pass to the Scheduler or override default ones in form of =") - init_phase_controlPlane_allCmd.Flags().String("service-cidr", "10.96.0.0/12", "Use alternative range of IP address for service VIPs.") + init_phase_controlPlane_allCmd.Flags().String("service-cidr", "", "Use alternative range of IP address for service VIPs.") + init_phase_controlPlane_allCmd.Flag("apiserver-extra-args").Hidden = true + init_phase_controlPlane_allCmd.Flag("controller-manager-extra-args").Hidden = true + init_phase_controlPlane_allCmd.Flag("scheduler-extra-args").Hidden = true init_phase_controlPlaneCmd.AddCommand(init_phase_controlPlane_allCmd) carapace.Gen(init_phase_controlPlane_allCmd).FlagCompletion(carapace.ActionMap{ - "cert-dir": carapace.ActionDirectories(), - "config": carapace.ActionFiles(), - "patches": carapace.ActionDirectories(), + "apiserver-bind-port": net.ActionPorts(), + "cert-dir": carapace.ActionDirectories(), + "config": carapace.ActionFiles(), + "feature-gates": kubeadm.ActionFeatureGates(), + "patches": carapace.ActionDirectories(), }) } diff --git a/completers/kubeadm_completer/cmd/init_phase_controlPlane_apiserver.go b/completers/kubeadm_completer/cmd/init_phase_controlPlane_apiserver.go index 85f16b28..5e85b004 100644 --- a/completers/kubeadm_completer/cmd/init_phase_controlPlane_apiserver.go +++ b/completers/kubeadm_completer/cmd/init_phase_controlPlane_apiserver.go @@ -2,6 +2,8 @@ package cmd import ( "github.com/carapace-sh/carapace" + "github.com/carapace-sh/carapace-bin/pkg/actions/net" + "github.com/carapace-sh/carapace-bin/pkg/actions/tools/kubeadm" "github.com/spf13/cobra" ) @@ -13,23 +15,27 @@ var init_phase_controlPlane_apiserverCmd = &cobra.Command{ func init() { carapace.Gen(init_phase_controlPlane_apiserverCmd).Standalone() + init_phase_controlPlane_apiserverCmd.Flags().String("apiserver-advertise-address", "", "The IP address the API Server will advertise it's listening on. If not set the default network interface will be used.") - init_phase_controlPlane_apiserverCmd.Flags().Int32("apiserver-bind-port", 6443, "Port for the API Server to bind to.") + init_phase_controlPlane_apiserverCmd.Flags().String("apiserver-bind-port", "", "Port for the API Server to bind to.") init_phase_controlPlane_apiserverCmd.Flags().String("apiserver-extra-args", "", "A set of extra flags to pass to the API Server or override default ones in form of =") - init_phase_controlPlane_apiserverCmd.Flags().String("cert-dir", "/etc/kubernetes/pki", "The path where to save and store the certificates.") + init_phase_controlPlane_apiserverCmd.Flags().String("cert-dir", "", "The path where to save and store the certificates.") init_phase_controlPlane_apiserverCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") init_phase_controlPlane_apiserverCmd.Flags().String("control-plane-endpoint", "", "Specify a stable IP address or DNS name for the control plane.") init_phase_controlPlane_apiserverCmd.Flags().Bool("dry-run", false, "Don't apply any changes; just output what would be done.") - init_phase_controlPlane_apiserverCmd.Flags().String("feature-gates", "", "A set of key=value pairs that describe feature gates for various features.") - init_phase_controlPlane_apiserverCmd.Flags().String("image-repository", "k8s.gcr.io", "Choose a container registry to pull control plane images from") - init_phase_controlPlane_apiserverCmd.Flags().String("kubernetes-version", "stable-1", "Choose a specific Kubernetes version for the control plane.") - init_phase_controlPlane_apiserverCmd.Flags().String("patches", "", "Path to a directory that contains files named \"target[suffix][+patchtype].extension\".") - init_phase_controlPlane_apiserverCmd.Flags().String("service-cidr", "10.96.0.0/12", "Use alternative range of IP address for service VIPs.") + init_phase_controlPlane_apiserverCmd.Flags().String("feature-gates", "", "A set of key=value pairs that describe feature gates for various features. Options are:") + init_phase_controlPlane_apiserverCmd.Flags().String("image-repository", "", "Choose a container registry to pull control plane images from") + init_phase_controlPlane_apiserverCmd.Flags().String("kubernetes-version", "", "Choose a specific Kubernetes version for the control plane.") + init_phase_controlPlane_apiserverCmd.Flags().String("patches", "", "Path to a directory that contains files named \"target[suffix][+patchtype].extension\". For example, \"kube-apiserver0+merge.yaml\" or just \"etcd.json\". \"target\" can be one of \"kube-apiserver\", \"kube-controller-manager\", \"kube-scheduler\", \"etcd\", \"kubeletconfiguration\", \"corednsdeployment\". \"patchtype\" can be one of \"strategic\", \"merge\" or \"json\" and they match the patch formats supported by kubectl. The default \"patchtype\" is \"strategic\". \"extension\" must be either \"json\" or \"yaml\". \"suffix\" is an optional string that can be used to determine which patches are applied first alpha-numerically.") + init_phase_controlPlane_apiserverCmd.Flags().String("service-cidr", "", "Use alternative range of IP address for service VIPs.") + init_phase_controlPlane_apiserverCmd.Flag("apiserver-extra-args").Hidden = true init_phase_controlPlaneCmd.AddCommand(init_phase_controlPlane_apiserverCmd) carapace.Gen(init_phase_controlPlane_apiserverCmd).FlagCompletion(carapace.ActionMap{ - "cert-dir": carapace.ActionDirectories(), - "config": carapace.ActionFiles(), - "patches": carapace.ActionDirectories(), + "apiserver-bind-port": net.ActionPorts(), + "cert-dir": carapace.ActionDirectories(), + "config": carapace.ActionFiles(), + "feature-gates": kubeadm.ActionFeatureGates(), + "patches": carapace.ActionDirectories(), }) } diff --git a/completers/kubeadm_completer/cmd/init_phase_controlPlane_controllerManager.go b/completers/kubeadm_completer/cmd/init_phase_controlPlane_controllerManager.go index a674c19c..ef752ea6 100644 --- a/completers/kubeadm_completer/cmd/init_phase_controlPlane_controllerManager.go +++ b/completers/kubeadm_completer/cmd/init_phase_controlPlane_controllerManager.go @@ -13,14 +13,16 @@ var init_phase_controlPlane_controllerManagerCmd = &cobra.Command{ func init() { carapace.Gen(init_phase_controlPlane_controllerManagerCmd).Standalone() - init_phase_controlPlane_controllerManagerCmd.Flags().String("cert-dir", "/etc/kubernetes/pki", "The path where to save and store the certificates.") + + init_phase_controlPlane_controllerManagerCmd.Flags().String("cert-dir", "", "The path where to save and store the certificates.") init_phase_controlPlane_controllerManagerCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") init_phase_controlPlane_controllerManagerCmd.Flags().String("controller-manager-extra-args", "", "A set of extra flags to pass to the Controller Manager or override default ones in form of =") init_phase_controlPlane_controllerManagerCmd.Flags().Bool("dry-run", false, "Don't apply any changes; just output what would be done.") - init_phase_controlPlane_controllerManagerCmd.Flags().String("image-repository", "k8s.gcr.io", "Choose a container registry to pull control plane images from") - init_phase_controlPlane_controllerManagerCmd.Flags().String("kubernetes-version", "stable-1", "Choose a specific Kubernetes version for the control plane.") - init_phase_controlPlane_controllerManagerCmd.Flags().String("patches", "", "Path to a directory that contains files named \"target[suffix][+patchtype].extension\".") + init_phase_controlPlane_controllerManagerCmd.Flags().String("image-repository", "", "Choose a container registry to pull control plane images from") + init_phase_controlPlane_controllerManagerCmd.Flags().String("kubernetes-version", "", "Choose a specific Kubernetes version for the control plane.") + init_phase_controlPlane_controllerManagerCmd.Flags().String("patches", "", "Path to a directory that contains files named \"target[suffix][+patchtype].extension\". For example, \"kube-apiserver0+merge.yaml\" or just \"etcd.json\". \"target\" can be one of \"kube-apiserver\", \"kube-controller-manager\", \"kube-scheduler\", \"etcd\", \"kubeletconfiguration\", \"corednsdeployment\". \"patchtype\" can be one of \"strategic\", \"merge\" or \"json\" and they match the patch formats supported by kubectl. The default \"patchtype\" is \"strategic\". \"extension\" must be either \"json\" or \"yaml\". \"suffix\" is an optional string that can be used to determine which patches are applied first alpha-numerically.") init_phase_controlPlane_controllerManagerCmd.Flags().String("pod-network-cidr", "", "Specify range of IP addresses for the pod network. If set, the control plane will automatically allocate CIDRs for every node.") + init_phase_controlPlane_controllerManagerCmd.Flag("controller-manager-extra-args").Hidden = true init_phase_controlPlaneCmd.AddCommand(init_phase_controlPlane_controllerManagerCmd) carapace.Gen(init_phase_controlPlane_controllerManagerCmd).FlagCompletion(carapace.ActionMap{ diff --git a/completers/kubeadm_completer/cmd/init_phase_etcd.go b/completers/kubeadm_completer/cmd/init_phase_etcd.go index 3e96ec8c..4655fbd4 100644 --- a/completers/kubeadm_completer/cmd/init_phase_etcd.go +++ b/completers/kubeadm_completer/cmd/init_phase_etcd.go @@ -13,5 +13,6 @@ var init_phase_etcdCmd = &cobra.Command{ func init() { carapace.Gen(init_phase_etcdCmd).Standalone() + init_phaseCmd.AddCommand(init_phase_etcdCmd) } diff --git a/completers/kubeadm_completer/cmd/init_phase_kubeconfig.go b/completers/kubeadm_completer/cmd/init_phase_kubeconfig.go index d87239b8..883b9700 100644 --- a/completers/kubeadm_completer/cmd/init_phase_kubeconfig.go +++ b/completers/kubeadm_completer/cmd/init_phase_kubeconfig.go @@ -13,5 +13,6 @@ var init_phase_kubeconfigCmd = &cobra.Command{ func init() { carapace.Gen(init_phase_kubeconfigCmd).Standalone() + init_phaseCmd.AddCommand(init_phase_kubeconfigCmd) } diff --git a/completers/kubeadm_completer/cmd/init_phase_kubeconfig_admin.go b/completers/kubeadm_completer/cmd/init_phase_kubeconfig_admin.go index 08ac2b68..ba364ccf 100644 --- a/completers/kubeadm_completer/cmd/init_phase_kubeconfig_admin.go +++ b/completers/kubeadm_completer/cmd/init_phase_kubeconfig_admin.go @@ -2,6 +2,7 @@ package cmd import ( "github.com/carapace-sh/carapace" + "github.com/carapace-sh/carapace-bin/pkg/actions/net" "github.com/spf13/cobra" ) @@ -13,18 +14,21 @@ var init_phase_kubeconfig_adminCmd = &cobra.Command{ func init() { carapace.Gen(init_phase_kubeconfig_adminCmd).Standalone() + init_phase_kubeconfig_adminCmd.Flags().String("apiserver-advertise-address", "", "The IP address the API Server will advertise it's listening on. If not set the default network interface will be used.") - init_phase_kubeconfig_adminCmd.Flags().Int32("apiserver-bind-port", 6443, "Port for the API Server to bind to.") - init_phase_kubeconfig_adminCmd.Flags().String("cert-dir", "/etc/kubernetes/pki", "The path where to save and store the certificates.") + init_phase_kubeconfig_adminCmd.Flags().String("apiserver-bind-port", "", "Port for the API Server to bind to.") + init_phase_kubeconfig_adminCmd.Flags().String("cert-dir", "", "The path where to save and store the certificates.") init_phase_kubeconfig_adminCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") init_phase_kubeconfig_adminCmd.Flags().String("control-plane-endpoint", "", "Specify a stable IP address or DNS name for the control plane.") - init_phase_kubeconfig_adminCmd.Flags().String("kubeconfig-dir", "/etc/kubernetes", "The path where to save the kubeconfig file.") - init_phase_kubeconfig_adminCmd.Flags().String("kubernetes-version", "stable-1", "Choose a specific Kubernetes version for the control plane.") + init_phase_kubeconfig_adminCmd.Flags().Bool("dry-run", false, "Don't apply any changes; just output what would be done.") + init_phase_kubeconfig_adminCmd.Flags().String("kubeconfig-dir", "", "The path where to save the kubeconfig file.") + init_phase_kubeconfig_adminCmd.Flags().String("kubernetes-version", "", "Choose a specific Kubernetes version for the control plane.") init_phase_kubeconfigCmd.AddCommand(init_phase_kubeconfig_adminCmd) carapace.Gen(init_phase_kubeconfig_adminCmd).FlagCompletion(carapace.ActionMap{ - "cert-dir": carapace.ActionDirectories(), - "config": carapace.ActionFiles(), - "kubeconfig-dir": carapace.ActionDirectories(), + "apiserver-bind-port": net.ActionPorts(), + "cert-dir": carapace.ActionDirectories(), + "config": carapace.ActionFiles(), + "kubeconfig-dir": carapace.ActionDirectories(), }) } diff --git a/completers/kubeadm_completer/cmd/init_phase_kubeconfig_controllerManager.go b/completers/kubeadm_completer/cmd/init_phase_kubeconfig_controllerManager.go index 70960713..9695a1a7 100644 --- a/completers/kubeadm_completer/cmd/init_phase_kubeconfig_controllerManager.go +++ b/completers/kubeadm_completer/cmd/init_phase_kubeconfig_controllerManager.go @@ -2,6 +2,7 @@ package cmd import ( "github.com/carapace-sh/carapace" + "github.com/carapace-sh/carapace-bin/pkg/actions/net" "github.com/spf13/cobra" ) @@ -13,18 +14,21 @@ var init_phase_kubeconfig_controllerManagerCmd = &cobra.Command{ func init() { carapace.Gen(init_phase_kubeconfig_controllerManagerCmd).Standalone() + init_phase_kubeconfig_controllerManagerCmd.Flags().String("apiserver-advertise-address", "", "The IP address the API Server will advertise it's listening on. If not set the default network interface will be used.") - init_phase_kubeconfig_controllerManagerCmd.Flags().Int32("apiserver-bind-port", 6443, "Port for the API Server to bind to.") - init_phase_kubeconfig_controllerManagerCmd.Flags().String("cert-dir", "/etc/kubernetes/pki", "The path where to save and store the certificates.") + init_phase_kubeconfig_controllerManagerCmd.Flags().String("apiserver-bind-port", "", "Port for the API Server to bind to.") + init_phase_kubeconfig_controllerManagerCmd.Flags().String("cert-dir", "", "The path where to save and store the certificates.") init_phase_kubeconfig_controllerManagerCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") init_phase_kubeconfig_controllerManagerCmd.Flags().String("control-plane-endpoint", "", "Specify a stable IP address or DNS name for the control plane.") - init_phase_kubeconfig_controllerManagerCmd.Flags().String("kubeconfig-dir", "/etc/kubernetes", "The path where to save the kubeconfig file.") - init_phase_kubeconfig_controllerManagerCmd.Flags().String("kubernetes-version", "stable-1", "Choose a specific Kubernetes version for the control plane.") + init_phase_kubeconfig_controllerManagerCmd.Flags().Bool("dry-run", false, "Don't apply any changes; just output what would be done.") + init_phase_kubeconfig_controllerManagerCmd.Flags().String("kubeconfig-dir", "", "The path where to save the kubeconfig file.") + init_phase_kubeconfig_controllerManagerCmd.Flags().String("kubernetes-version", "", "Choose a specific Kubernetes version for the control plane.") init_phase_kubeconfigCmd.AddCommand(init_phase_kubeconfig_controllerManagerCmd) carapace.Gen(init_phase_kubeconfig_controllerManagerCmd).FlagCompletion(carapace.ActionMap{ - "cert-dir": carapace.ActionDirectories(), - "config": carapace.ActionFiles(), - "kubeconfig-dir": carapace.ActionDirectories(), + "apiserver-bind-port": net.ActionPorts(), + "cert-dir": carapace.ActionDirectories(), + "config": carapace.ActionFiles(), + "kubeconfig-dir": carapace.ActionDirectories(), }) } diff --git a/completers/kubeadm_completer/cmd/init_phase_kubeconfig_kubelet.go b/completers/kubeadm_completer/cmd/init_phase_kubeconfig_kubelet.go index 297c5b2a..f4e072d5 100644 --- a/completers/kubeadm_completer/cmd/init_phase_kubeconfig_kubelet.go +++ b/completers/kubeadm_completer/cmd/init_phase_kubeconfig_kubelet.go @@ -2,6 +2,7 @@ package cmd import ( "github.com/carapace-sh/carapace" + "github.com/carapace-sh/carapace-bin/pkg/actions/net" "github.com/spf13/cobra" ) @@ -13,19 +14,22 @@ var init_phase_kubeconfig_kubeletCmd = &cobra.Command{ func init() { carapace.Gen(init_phase_kubeconfig_kubeletCmd).Standalone() + init_phase_kubeconfig_kubeletCmd.Flags().String("apiserver-advertise-address", "", "The IP address the API Server will advertise it's listening on. If not set the default network interface will be used.") - init_phase_kubeconfig_kubeletCmd.Flags().Int32("apiserver-bind-port", 6443, "Port for the API Server to bind to.") - init_phase_kubeconfig_kubeletCmd.Flags().String("cert-dir", "/etc/kubernetes/pki", "The path where to save and store the certificates.") + init_phase_kubeconfig_kubeletCmd.Flags().String("apiserver-bind-port", "", "Port for the API Server to bind to.") + init_phase_kubeconfig_kubeletCmd.Flags().String("cert-dir", "", "The path where to save and store the certificates.") init_phase_kubeconfig_kubeletCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") init_phase_kubeconfig_kubeletCmd.Flags().String("control-plane-endpoint", "", "Specify a stable IP address or DNS name for the control plane.") - init_phase_kubeconfig_kubeletCmd.Flags().String("kubeconfig-dir", "/etc/kubernetes", "The path where to save the kubeconfig file.") - init_phase_kubeconfig_kubeletCmd.Flags().String("kubernetes-version", "stable-1", "Choose a specific Kubernetes version for the control plane.") + init_phase_kubeconfig_kubeletCmd.Flags().Bool("dry-run", false, "Don't apply any changes; just output what would be done.") + init_phase_kubeconfig_kubeletCmd.Flags().String("kubeconfig-dir", "", "The path where to save the kubeconfig file.") + init_phase_kubeconfig_kubeletCmd.Flags().String("kubernetes-version", "", "Choose a specific Kubernetes version for the control plane.") init_phase_kubeconfig_kubeletCmd.Flags().String("node-name", "", "Specify the node name.") init_phase_kubeconfigCmd.AddCommand(init_phase_kubeconfig_kubeletCmd) carapace.Gen(init_phase_kubeconfig_kubeletCmd).FlagCompletion(carapace.ActionMap{ - "cert-dir": carapace.ActionDirectories(), - "config": carapace.ActionFiles(), - "kubeconfig-dir": carapace.ActionDirectories(), + "apiserver-bind-port": net.ActionPorts(), + "cert-dir": carapace.ActionDirectories(), + "config": carapace.ActionFiles(), + "kubeconfig-dir": carapace.ActionDirectories(), }) } diff --git a/completers/kubeadm_completer/cmd/init_phase_kubeconfig_scheduler.go b/completers/kubeadm_completer/cmd/init_phase_kubeconfig_scheduler.go index 9dc68694..c3293a80 100644 --- a/completers/kubeadm_completer/cmd/init_phase_kubeconfig_scheduler.go +++ b/completers/kubeadm_completer/cmd/init_phase_kubeconfig_scheduler.go @@ -2,6 +2,7 @@ package cmd import ( "github.com/carapace-sh/carapace" + "github.com/carapace-sh/carapace-bin/pkg/actions/net" "github.com/spf13/cobra" ) @@ -13,18 +14,21 @@ var init_phase_kubeconfig_schedulerCmd = &cobra.Command{ func init() { carapace.Gen(init_phase_kubeconfig_schedulerCmd).Standalone() + init_phase_kubeconfig_schedulerCmd.Flags().String("apiserver-advertise-address", "", "The IP address the API Server will advertise it's listening on. If not set the default network interface will be used.") - init_phase_kubeconfig_schedulerCmd.Flags().Int32("apiserver-bind-port", 6443, "Port for the API Server to bind to.") - init_phase_kubeconfig_schedulerCmd.Flags().String("cert-dir", "/etc/kubernetes/pki", "The path where to save and store the certificates.") + init_phase_kubeconfig_schedulerCmd.Flags().String("apiserver-bind-port", "", "Port for the API Server to bind to.") + init_phase_kubeconfig_schedulerCmd.Flags().String("cert-dir", "", "The path where to save and store the certificates.") init_phase_kubeconfig_schedulerCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") init_phase_kubeconfig_schedulerCmd.Flags().String("control-plane-endpoint", "", "Specify a stable IP address or DNS name for the control plane.") - init_phase_kubeconfig_schedulerCmd.Flags().String("kubeconfig-dir", "/etc/kubernetes", "The path where to save the kubeconfig file.") - init_phase_kubeconfig_schedulerCmd.Flags().String("kubernetes-version", "stable-1", "Choose a specific Kubernetes version for the control plane.") + init_phase_kubeconfig_schedulerCmd.Flags().Bool("dry-run", false, "Don't apply any changes; just output what would be done.") + init_phase_kubeconfig_schedulerCmd.Flags().String("kubeconfig-dir", "", "The path where to save the kubeconfig file.") + init_phase_kubeconfig_schedulerCmd.Flags().String("kubernetes-version", "", "Choose a specific Kubernetes version for the control plane.") init_phase_kubeconfigCmd.AddCommand(init_phase_kubeconfig_schedulerCmd) carapace.Gen(init_phase_kubeconfig_schedulerCmd).FlagCompletion(carapace.ActionMap{ - "cert-dir": carapace.ActionDirectories(), - "config": carapace.ActionFiles(), - "kubeconfig-dir": carapace.ActionDirectories(), + "apiserver-bind-port": net.ActionPorts(), + "cert-dir": carapace.ActionDirectories(), + "config": carapace.ActionFiles(), + "kubeconfig-dir": carapace.ActionDirectories(), }) } diff --git a/completers/kubeadm_completer/cmd/init_phase_kubeconfig_superAdmin.go b/completers/kubeadm_completer/cmd/init_phase_kubeconfig_superAdmin.go new file mode 100644 index 00000000..7b1bb584 --- /dev/null +++ b/completers/kubeadm_completer/cmd/init_phase_kubeconfig_superAdmin.go @@ -0,0 +1,35 @@ +package cmd + +import ( + "github.com/carapace-sh/carapace" + "github.com/carapace-sh/carapace-bin/pkg/actions/net" + "github.com/spf13/cobra" +) + +var init_phase_kubeconfig_superAdminCmd = &cobra.Command{ + Use: "super-admin", + Short: "Generate a kubeconfig file for the super-admin", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(init_phase_kubeconfig_superAdminCmd).Standalone() + + init_phase_kubeconfig_superAdminCmd.Flags().String("apiserver-advertise-address", "", "The IP address the API Server will advertise it's listening on. If not set the default network interface will be used.") + init_phase_kubeconfig_superAdminCmd.Flags().String("apiserver-bind-port", "", "Port for the API Server to bind to.") + init_phase_kubeconfig_superAdminCmd.Flags().String("cert-dir", "", "The path where to save and store the certificates.") + init_phase_kubeconfig_superAdminCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") + init_phase_kubeconfig_superAdminCmd.Flags().String("control-plane-endpoint", "", "Specify a stable IP address or DNS name for the control plane.") + init_phase_kubeconfig_superAdminCmd.Flags().Bool("dry-run", false, "Don't apply any changes; just output what would be done.") + init_phase_kubeconfig_superAdminCmd.Flags().String("kubeconfig-dir", "", "The path where to save the kubeconfig file.") + init_phase_kubeconfig_superAdminCmd.Flags().String("kubernetes-version", "", "Choose a specific Kubernetes version for the control plane.") + init_phase_kubeconfigCmd.AddCommand(init_phase_kubeconfig_superAdminCmd) + + carapace.Gen(init_phase_kubeconfig_superAdminCmd).FlagCompletion(carapace.ActionMap{ + "apiserver-bind-port": net.ActionPorts(), + "cert-dir": carapace.ActionDirectories(), + "config": carapace.ActionFiles(), + "kubeconfig-dir": carapace.ActionDirectories(), + }) + +} diff --git a/completers/kubeadm_completer/cmd/init_phase_kubeletFinalize.go b/completers/kubeadm_completer/cmd/init_phase_kubeletFinalize.go index 1f2f8702..7ed0f51b 100644 --- a/completers/kubeadm_completer/cmd/init_phase_kubeletFinalize.go +++ b/completers/kubeadm_completer/cmd/init_phase_kubeletFinalize.go @@ -13,5 +13,6 @@ var init_phase_kubeletFinalizeCmd = &cobra.Command{ func init() { carapace.Gen(init_phase_kubeletFinalizeCmd).Standalone() + init_phaseCmd.AddCommand(init_phase_kubeletFinalizeCmd) } diff --git a/completers/kubeadm_completer/cmd/init_phase_kubeletFinalize_all.go b/completers/kubeadm_completer/cmd/init_phase_kubeletFinalize_all.go index bbe615ad..6fa664e5 100644 --- a/completers/kubeadm_completer/cmd/init_phase_kubeletFinalize_all.go +++ b/completers/kubeadm_completer/cmd/init_phase_kubeletFinalize_all.go @@ -13,8 +13,10 @@ var init_phase_kubeletFinalize_allCmd = &cobra.Command{ func init() { carapace.Gen(init_phase_kubeletFinalize_allCmd).Standalone() - init_phase_kubeletFinalize_allCmd.Flags().String("cert-dir", "/etc/kubernetes/pki", "The path where to save and store the certificates.") + + init_phase_kubeletFinalize_allCmd.Flags().String("cert-dir", "", "The path where to save and store the certificates.") init_phase_kubeletFinalize_allCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") + init_phase_kubeletFinalize_allCmd.Flags().Bool("dry-run", false, "Don't apply any changes; just output what would be done.") init_phase_kubeletFinalizeCmd.AddCommand(init_phase_kubeletFinalize_allCmd) carapace.Gen(init_phase_kubeletFinalize_allCmd).FlagCompletion(carapace.ActionMap{ diff --git a/completers/kubeadm_completer/cmd/init_phase_kubeletFinalize_enableClientCertRotation.go b/completers/kubeadm_completer/cmd/init_phase_kubeletFinalize_enableClientCertRotation.go new file mode 100644 index 00000000..56466a79 --- /dev/null +++ b/completers/kubeadm_completer/cmd/init_phase_kubeletFinalize_enableClientCertRotation.go @@ -0,0 +1,26 @@ +package cmd + +import ( + "github.com/carapace-sh/carapace" + "github.com/spf13/cobra" +) + +var init_phase_kubeletFinalize_enableClientCertRotationCmd = &cobra.Command{ + Use: "enable-client-cert-rotation", + Short: "Enable kubelet client certificate rotation", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(init_phase_kubeletFinalize_enableClientCertRotationCmd).Standalone() + + init_phase_kubeletFinalize_enableClientCertRotationCmd.Flags().String("cert-dir", "", "The path where to save and store the certificates.") + init_phase_kubeletFinalize_enableClientCertRotationCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") + init_phase_kubeletFinalize_enableClientCertRotationCmd.Flags().Bool("dry-run", false, "Don't apply any changes; just output what would be done.") + init_phase_kubeletFinalizeCmd.AddCommand(init_phase_kubeletFinalize_enableClientCertRotationCmd) + + carapace.Gen(init_phase_kubeletFinalize_enableClientCertRotationCmd).FlagCompletion(carapace.ActionMap{ + "cert-dir": carapace.ActionDirectories(), + "config": carapace.ActionFiles(), + }) +} diff --git a/completers/kubeadm_completer/cmd/init_phase_kubeletFinalize_experimentalCertRotation.go b/completers/kubeadm_completer/cmd/init_phase_kubeletFinalize_experimentalCertRotation.go deleted file mode 100644 index 2532e483..00000000 --- a/completers/kubeadm_completer/cmd/init_phase_kubeletFinalize_experimentalCertRotation.go +++ /dev/null @@ -1,24 +0,0 @@ -package cmd - -import ( - "github.com/carapace-sh/carapace" - "github.com/spf13/cobra" -) - -var init_phase_kubeletFinalize_experimentalCertRotationCmd = &cobra.Command{ - Use: "experimental-cert-rotation", - Short: "Enable kubelet client certificate rotation", - Run: func(cmd *cobra.Command, args []string) {}, -} - -func init() { - carapace.Gen(init_phase_kubeletFinalize_experimentalCertRotationCmd).Standalone() - init_phase_kubeletFinalize_experimentalCertRotationCmd.Flags().String("cert-dir", "/etc/kubernetes/pki", "The path where to save and store the certificates.") - init_phase_kubeletFinalize_experimentalCertRotationCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") - init_phase_kubeletFinalizeCmd.AddCommand(init_phase_kubeletFinalize_experimentalCertRotationCmd) - - carapace.Gen(init_phase_kubeletFinalize_experimentalCertRotationCmd).FlagCompletion(carapace.ActionMap{ - "cert-dir": carapace.ActionDirectories(), - "config": carapace.ActionFiles(), - }) -} diff --git a/completers/kubeadm_completer/cmd/init_phase_kubeletStart.go b/completers/kubeadm_completer/cmd/init_phase_kubeletStart.go index 52c00cc2..c545aee9 100644 --- a/completers/kubeadm_completer/cmd/init_phase_kubeletStart.go +++ b/completers/kubeadm_completer/cmd/init_phase_kubeletStart.go @@ -13,9 +13,13 @@ var init_phase_kubeletStartCmd = &cobra.Command{ func init() { carapace.Gen(init_phase_kubeletStartCmd).Standalone() + init_phase_kubeletStartCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") init_phase_kubeletStartCmd.Flags().String("cri-socket", "", "Path to the CRI socket to connect. If empty kubeadm will try to auto-detect this value; use this option only if you have more than one CRI installed or if you have non-standard CRI socket.") + init_phase_kubeletStartCmd.Flags().Bool("dry-run", false, "Don't apply any changes; just output what would be done.") + init_phase_kubeletStartCmd.Flags().String("image-repository", "", "Choose a container registry to pull control plane images from") init_phase_kubeletStartCmd.Flags().String("node-name", "", "Specify the node name.") + init_phase_kubeletStartCmd.Flags().String("patches", "", "Path to a directory that contains files named \"target[suffix][+patchtype].extension\". For example, \"kube-apiserver0+merge.yaml\" or just \"etcd.json\". \"target\" can be one of \"kube-apiserver\", \"kube-controller-manager\", \"kube-scheduler\", \"etcd\", \"kubeletconfiguration\", \"corednsdeployment\". \"patchtype\" can be one of \"strategic\", \"merge\" or \"json\" and they match the patch formats supported by kubectl. The default \"patchtype\" is \"strategic\". \"extension\" must be either \"json\" or \"yaml\". \"suffix\" is an optional string that can be used to determine which patches are applied first alpha-numerically.") init_phaseCmd.AddCommand(init_phase_kubeletStartCmd) carapace.Gen(init_phase_kubeletStartCmd).FlagCompletion(carapace.ActionMap{ diff --git a/completers/kubeadm_completer/cmd/init_phase_markControlPlane.go b/completers/kubeadm_completer/cmd/init_phase_markControlPlane.go index 610f4509..8731b366 100644 --- a/completers/kubeadm_completer/cmd/init_phase_markControlPlane.go +++ b/completers/kubeadm_completer/cmd/init_phase_markControlPlane.go @@ -13,7 +13,9 @@ var init_phase_markControlPlaneCmd = &cobra.Command{ func init() { carapace.Gen(init_phase_markControlPlaneCmd).Standalone() + init_phase_markControlPlaneCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") + init_phase_markControlPlaneCmd.Flags().Bool("dry-run", false, "Don't apply any changes; just output what would be done.") init_phase_markControlPlaneCmd.Flags().String("node-name", "", "Specify the node name.") init_phaseCmd.AddCommand(init_phase_markControlPlaneCmd) diff --git a/completers/kubeadm_completer/cmd/init_phase_preflight.go b/completers/kubeadm_completer/cmd/init_phase_preflight.go index 44e566c6..cc99f319 100644 --- a/completers/kubeadm_completer/cmd/init_phase_preflight.go +++ b/completers/kubeadm_completer/cmd/init_phase_preflight.go @@ -14,8 +14,12 @@ var init_phase_preflightCmd = &cobra.Command{ func init() { carapace.Gen(init_phase_preflightCmd).Standalone() + init_phase_preflightCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") + init_phase_preflightCmd.Flags().String("cri-socket", "", "Path to the CRI socket to connect. If empty kubeadm will try to auto-detect this value; use this option only if you have more than one CRI installed or if you have non-standard CRI socket.") + init_phase_preflightCmd.Flags().Bool("dry-run", false, "Don't apply any changes; just output what would be done.") init_phase_preflightCmd.Flags().StringSlice("ignore-preflight-errors", []string{}, "A list of checks whose errors will be shown as warnings. Example: 'IsPrivilegedUser,Swap'. Value 'all' ignores errors from all checks.") + init_phase_preflightCmd.Flags().String("image-repository", "", "Choose a container registry to pull control plane images from") init_phaseCmd.AddCommand(init_phase_preflightCmd) carapace.Gen(init_phase_preflightCmd).FlagCompletion(carapace.ActionMap{ diff --git a/completers/kubeadm_completer/cmd/init_phase_showJoinCommand.go b/completers/kubeadm_completer/cmd/init_phase_showJoinCommand.go new file mode 100644 index 00000000..26e4fe44 --- /dev/null +++ b/completers/kubeadm_completer/cmd/init_phase_showJoinCommand.go @@ -0,0 +1,18 @@ +package cmd + +import ( + "github.com/carapace-sh/carapace" + "github.com/spf13/cobra" +) + +var init_phase_showJoinCommandCmd = &cobra.Command{ + Use: "show-join-command", + Short: "Show the join command for control-plane and worker node", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(init_phase_showJoinCommandCmd).Standalone() + + init_phaseCmd.AddCommand(init_phase_showJoinCommandCmd) +} diff --git a/completers/kubeadm_completer/cmd/init_phase_uploadCerts.go b/completers/kubeadm_completer/cmd/init_phase_uploadCerts.go index 4ac465ff..3c4ec616 100644 --- a/completers/kubeadm_completer/cmd/init_phase_uploadCerts.go +++ b/completers/kubeadm_completer/cmd/init_phase_uploadCerts.go @@ -13,9 +13,11 @@ var init_phase_uploadCertsCmd = &cobra.Command{ func init() { carapace.Gen(init_phase_uploadCertsCmd).Standalone() - init_phase_uploadCertsCmd.Flags().String("certificate-key", "", "Key used to encrypt the control-plane certificates in the kubeadm-certs Secret.") + + init_phase_uploadCertsCmd.Flags().String("certificate-key", "", "Key used to encrypt the control-plane certificates in the kubeadm-certs Secret. The certificate key is a hex encoded string that is an AES key of size 32 bytes.") init_phase_uploadCertsCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") - init_phase_uploadCertsCmd.Flags().String("kubeconfig", "/etc/kubernetes/admin.conf", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") + init_phase_uploadCertsCmd.Flags().Bool("dry-run", false, "Don't apply any changes; just output what would be done.") + init_phase_uploadCertsCmd.Flags().String("kubeconfig", "", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") init_phase_uploadCertsCmd.Flags().Bool("skip-certificate-key-print", false, "Don't print the key used to encrypt the control-plane certificates.") init_phase_uploadCertsCmd.Flags().Bool("upload-certs", false, "Upload control-plane certificates to the kubeadm-certs Secret.") init_phaseCmd.AddCommand(init_phase_uploadCertsCmd) diff --git a/completers/kubeadm_completer/cmd/init_phase_uploadConfig.go b/completers/kubeadm_completer/cmd/init_phase_uploadConfig.go index 5fc1ced0..92382a3b 100644 --- a/completers/kubeadm_completer/cmd/init_phase_uploadConfig.go +++ b/completers/kubeadm_completer/cmd/init_phase_uploadConfig.go @@ -6,12 +6,14 @@ import ( ) var init_phase_uploadConfigCmd = &cobra.Command{ - Use: "upload-config", - Short: "Upload the kubeadm and kubelet configuration to a ConfigMap", - Run: func(cmd *cobra.Command, args []string) {}, + Use: "upload-config", + Short: "Upload the kubeadm and kubelet configuration to a ConfigMap", + Aliases: []string{"uploadconfig"}, + Run: func(cmd *cobra.Command, args []string) {}, } func init() { carapace.Gen(init_phase_uploadConfigCmd).Standalone() + init_phaseCmd.AddCommand(init_phase_uploadConfigCmd) } diff --git a/completers/kubeadm_completer/cmd/init_phase_uploadConfig_all.go b/completers/kubeadm_completer/cmd/init_phase_uploadConfig_all.go index ffde73e6..0bd830e9 100644 --- a/completers/kubeadm_completer/cmd/init_phase_uploadConfig_all.go +++ b/completers/kubeadm_completer/cmd/init_phase_uploadConfig_all.go @@ -13,8 +13,11 @@ var init_phase_uploadConfig_allCmd = &cobra.Command{ func init() { carapace.Gen(init_phase_uploadConfig_allCmd).Standalone() + init_phase_uploadConfig_allCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") - init_phase_uploadConfig_allCmd.Flags().String("kubeconfig", "/etc/kubernetes/admin.conf", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") + init_phase_uploadConfig_allCmd.Flags().String("cri-socket", "", "Path to the CRI socket to connect. If empty kubeadm will try to auto-detect this value; use this option only if you have more than one CRI installed or if you have non-standard CRI socket.") + init_phase_uploadConfig_allCmd.Flags().Bool("dry-run", false, "Don't apply any changes; just output what would be done.") + init_phase_uploadConfig_allCmd.Flags().String("kubeconfig", "", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") init_phase_uploadConfigCmd.AddCommand(init_phase_uploadConfig_allCmd) carapace.Gen(init_phase_uploadConfig_allCmd).FlagCompletion(carapace.ActionMap{ diff --git a/completers/kubeadm_completer/cmd/init_phase_uploadConfig_kubeadm.go b/completers/kubeadm_completer/cmd/init_phase_uploadConfig_kubeadm.go index c8f64656..3394c85c 100644 --- a/completers/kubeadm_completer/cmd/init_phase_uploadConfig_kubeadm.go +++ b/completers/kubeadm_completer/cmd/init_phase_uploadConfig_kubeadm.go @@ -13,8 +13,11 @@ var init_phase_uploadConfig_kubeadmCmd = &cobra.Command{ func init() { carapace.Gen(init_phase_uploadConfig_kubeadmCmd).Standalone() + init_phase_uploadConfig_kubeadmCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") - init_phase_uploadConfig_kubeadmCmd.Flags().String("kubeconfig", "/etc/kubernetes/admin.conf", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") + init_phase_uploadConfig_kubeadmCmd.Flags().String("cri-socket", "", "Path to the CRI socket to connect. If empty kubeadm will try to auto-detect this value; use this option only if you have more than one CRI installed or if you have non-standard CRI socket.") + init_phase_uploadConfig_kubeadmCmd.Flags().Bool("dry-run", false, "Don't apply any changes; just output what would be done.") + init_phase_uploadConfig_kubeadmCmd.Flags().String("kubeconfig", "", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") init_phase_uploadConfigCmd.AddCommand(init_phase_uploadConfig_kubeadmCmd) carapace.Gen(init_phase_uploadConfig_kubeadmCmd).FlagCompletion(carapace.ActionMap{ diff --git a/completers/kubeadm_completer/cmd/init_phase_uploadConfig_kubelet.go b/completers/kubeadm_completer/cmd/init_phase_uploadConfig_kubelet.go index 161779fe..3b0f9d23 100644 --- a/completers/kubeadm_completer/cmd/init_phase_uploadConfig_kubelet.go +++ b/completers/kubeadm_completer/cmd/init_phase_uploadConfig_kubelet.go @@ -13,8 +13,11 @@ var init_phase_uploadConfig_kubeletCmd = &cobra.Command{ func init() { carapace.Gen(init_phase_uploadConfig_kubeletCmd).Standalone() + init_phase_uploadConfig_kubeletCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") - init_phase_uploadConfig_kubeletCmd.Flags().String("kubeconfig", "/etc/kubernetes/admin.conf", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") + init_phase_uploadConfig_kubeletCmd.Flags().String("cri-socket", "", "Path to the CRI socket to connect. If empty kubeadm will try to auto-detect this value; use this option only if you have more than one CRI installed or if you have non-standard CRI socket.") + init_phase_uploadConfig_kubeletCmd.Flags().Bool("dry-run", false, "Don't apply any changes; just output what would be done.") + init_phase_uploadConfig_kubeletCmd.Flags().String("kubeconfig", "", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") init_phase_uploadConfigCmd.AddCommand(init_phase_uploadConfig_kubeletCmd) carapace.Gen(init_phase_uploadConfig_kubeletCmd).FlagCompletion(carapace.ActionMap{ diff --git a/completers/kubeadm_completer/cmd/join.go b/completers/kubeadm_completer/cmd/join.go index 3435c479..e9f7e221 100644 --- a/completers/kubeadm_completer/cmd/join.go +++ b/completers/kubeadm_completer/cmd/join.go @@ -3,21 +3,23 @@ package cmd import ( "github.com/carapace-sh/carapace" "github.com/carapace-sh/carapace-bin/completers/kubeadm_completer/cmd/action" + "github.com/carapace-sh/carapace-bin/pkg/actions/net" "github.com/spf13/cobra" ) var joinCmd = &cobra.Command{ - Use: "join", + Use: "join [api-server-endpoint]", Short: "Run this on any machine you wish to join an existing cluster", Run: func(cmd *cobra.Command, args []string) {}, } func init() { carapace.Gen(joinCmd).Standalone() + joinCmd.Flags().String("apiserver-advertise-address", "", "If the node should host a new control plane instance, the IP address the API Server will advertise it's listening on. If not set the default network interface will be used.") - joinCmd.Flags().Int32("apiserver-bind-port", 6443, "If the node should host a new control plane instance, the port for the API Server to bind to.") - joinCmd.Flags().String("certificate-key", "", "Use this key to decrypt the certificate secrets uploaded by init.") - joinCmd.Flags().String("config", "", "Path to kubeadm config file.") + joinCmd.Flags().String("apiserver-bind-port", "", "If the node should host a new control plane instance, the port for the API Server to bind to.") + joinCmd.Flags().String("certificate-key", "", "Use this key to decrypt the certificate secrets uploaded by init. The certificate key is a hex encoded string that is an AES key of size 32 bytes.") + joinCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") joinCmd.Flags().Bool("control-plane", false, "Create a new control plane instance on this node") joinCmd.Flags().String("cri-socket", "", "Path to the CRI socket to connect. If empty kubeadm will try to auto-detect this value; use this option only if you have more than one CRI installed or if you have non-standard CRI socket.") joinCmd.Flags().String("discovery-file", "", "For file-based discovery, a file or URL from which to load cluster information.") @@ -27,13 +29,14 @@ func init() { joinCmd.Flags().Bool("dry-run", false, "Don't apply any changes; just output what would be done.") joinCmd.Flags().StringSlice("ignore-preflight-errors", []string{}, "A list of checks whose errors will be shown as warnings. Example: 'IsPrivilegedUser,Swap'. Value 'all' ignores errors from all checks.") joinCmd.Flags().String("node-name", "", "Specify the node name.") - joinCmd.Flags().String("patches", "", "Path to a directory that contains files named \"target[suffix][+patchtype].extension\".") + joinCmd.Flags().String("patches", "", "Path to a directory that contains files named \"target[suffix][+patchtype].extension\". For example, \"kube-apiserver0+merge.yaml\" or just \"etcd.json\". \"target\" can be one of \"kube-apiserver\", \"kube-controller-manager\", \"kube-scheduler\", \"etcd\", \"kubeletconfiguration\", \"corednsdeployment\". \"patchtype\" can be one of \"strategic\", \"merge\" or \"json\" and they match the patch formats supported by kubectl. The default \"patchtype\" is \"strategic\". \"extension\" must be either \"json\" or \"yaml\". \"suffix\" is an optional string that can be used to determine which patches are applied first alpha-numerically.") joinCmd.Flags().StringSlice("skip-phases", []string{}, "List of phases to be skipped") joinCmd.Flags().String("tls-bootstrap-token", "", "Specify the token used to temporarily authenticate with the Kubernetes Control Plane while joining the node.") joinCmd.Flags().String("token", "", "Use this token for both discovery-token and tls-bootstrap-token when those values are not provided.") rootCmd.AddCommand(joinCmd) carapace.Gen(joinCmd).FlagCompletion(carapace.ActionMap{ + "apiserver-bind-port": net.ActionPorts(), "config": carapace.ActionFiles(), "cri-socket": carapace.ActionFiles(), "discovery-file": carapace.ActionFiles(), diff --git a/completers/kubeadm_completer/cmd/join_phase.go b/completers/kubeadm_completer/cmd/join_phase.go index 10d5631d..d613067e 100644 --- a/completers/kubeadm_completer/cmd/join_phase.go +++ b/completers/kubeadm_completer/cmd/join_phase.go @@ -7,11 +7,12 @@ import ( var join_phaseCmd = &cobra.Command{ Use: "phase", - Short: "Use this command to invoke single phase of the join workflow", + Short: "Use this command to invoke single phase of the \"join\" workflow", Run: func(cmd *cobra.Command, args []string) {}, } func init() { carapace.Gen(join_phaseCmd).Standalone() + joinCmd.AddCommand(join_phaseCmd) } diff --git a/completers/kubeadm_completer/cmd/join_phase_controlPlaneJoin.go b/completers/kubeadm_completer/cmd/join_phase_controlPlaneJoin.go index e7b43011..c063c57d 100644 --- a/completers/kubeadm_completer/cmd/join_phase_controlPlaneJoin.go +++ b/completers/kubeadm_completer/cmd/join_phase_controlPlaneJoin.go @@ -13,5 +13,6 @@ var join_phase_controlPlaneJoinCmd = &cobra.Command{ func init() { carapace.Gen(join_phase_controlPlaneJoinCmd).Standalone() + join_phaseCmd.AddCommand(join_phase_controlPlaneJoinCmd) } diff --git a/completers/kubeadm_completer/cmd/join_phase_controlPlaneJoin_all.go b/completers/kubeadm_completer/cmd/join_phase_controlPlaneJoin_all.go index 793f30fd..15480665 100644 --- a/completers/kubeadm_completer/cmd/join_phase_controlPlaneJoin_all.go +++ b/completers/kubeadm_completer/cmd/join_phase_controlPlaneJoin_all.go @@ -13,11 +13,13 @@ var join_phase_controlPlaneJoin_allCmd = &cobra.Command{ func init() { carapace.Gen(join_phase_controlPlaneJoin_allCmd).Standalone() + join_phase_controlPlaneJoin_allCmd.Flags().String("apiserver-advertise-address", "", "If the node should host a new control plane instance, the IP address the API Server will advertise it's listening on. If not set the default network interface will be used.") - join_phase_controlPlaneJoin_allCmd.Flags().String("config", "", "Path to kubeadm config file.") + join_phase_controlPlaneJoin_allCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") join_phase_controlPlaneJoin_allCmd.Flags().Bool("control-plane", false, "Create a new control plane instance on this node") + join_phase_controlPlaneJoin_allCmd.Flags().Bool("dry-run", false, "Don't apply any changes; just output what would be done.") join_phase_controlPlaneJoin_allCmd.Flags().String("node-name", "", "Specify the node name.") - join_phase_controlPlaneJoin_allCmd.Flags().String("patches", "", "Path to a directory that contains files named \"target[suffix][+patchtype].extension\".") + join_phase_controlPlaneJoin_allCmd.Flags().String("patches", "", "Path to a directory that contains files named \"target[suffix][+patchtype].extension\". For example, \"kube-apiserver0+merge.yaml\" or just \"etcd.json\". \"target\" can be one of \"kube-apiserver\", \"kube-controller-manager\", \"kube-scheduler\", \"etcd\", \"kubeletconfiguration\", \"corednsdeployment\". \"patchtype\" can be one of \"strategic\", \"merge\" or \"json\" and they match the patch formats supported by kubectl. The default \"patchtype\" is \"strategic\". \"extension\" must be either \"json\" or \"yaml\". \"suffix\" is an optional string that can be used to determine which patches are applied first alpha-numerically.") join_phase_controlPlaneJoinCmd.AddCommand(join_phase_controlPlaneJoin_allCmd) carapace.Gen(join_phase_controlPlaneJoin_allCmd).FlagCompletion(carapace.ActionMap{ diff --git a/completers/kubeadm_completer/cmd/join_phase_controlPlaneJoin_etcd.go b/completers/kubeadm_completer/cmd/join_phase_controlPlaneJoin_etcd.go index 6ac89605..c170df87 100644 --- a/completers/kubeadm_completer/cmd/join_phase_controlPlaneJoin_etcd.go +++ b/completers/kubeadm_completer/cmd/join_phase_controlPlaneJoin_etcd.go @@ -13,11 +13,13 @@ var join_phase_controlPlaneJoin_etcdCmd = &cobra.Command{ func init() { carapace.Gen(join_phase_controlPlaneJoin_etcdCmd).Standalone() + join_phase_controlPlaneJoin_etcdCmd.Flags().String("apiserver-advertise-address", "", "If the node should host a new control plane instance, the IP address the API Server will advertise it's listening on. If not set the default network interface will be used.") - join_phase_controlPlaneJoin_etcdCmd.Flags().String("config", "", "Path to kubeadm config file.") + join_phase_controlPlaneJoin_etcdCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") join_phase_controlPlaneJoin_etcdCmd.Flags().Bool("control-plane", false, "Create a new control plane instance on this node") + join_phase_controlPlaneJoin_etcdCmd.Flags().Bool("dry-run", false, "Don't apply any changes; just output what would be done.") join_phase_controlPlaneJoin_etcdCmd.Flags().String("node-name", "", "Specify the node name.") - join_phase_controlPlaneJoin_etcdCmd.Flags().String("patches", "", "Path to a directory that contains files named \"target[suffix][+patchtype].extension\".") + join_phase_controlPlaneJoin_etcdCmd.Flags().String("patches", "", "Path to a directory that contains files named \"target[suffix][+patchtype].extension\". For example, \"kube-apiserver0+merge.yaml\" or just \"etcd.json\". \"target\" can be one of \"kube-apiserver\", \"kube-controller-manager\", \"kube-scheduler\", \"etcd\", \"kubeletconfiguration\", \"corednsdeployment\". \"patchtype\" can be one of \"strategic\", \"merge\" or \"json\" and they match the patch formats supported by kubectl. The default \"patchtype\" is \"strategic\". \"extension\" must be either \"json\" or \"yaml\". \"suffix\" is an optional string that can be used to determine which patches are applied first alpha-numerically.") join_phase_controlPlaneJoinCmd.AddCommand(join_phase_controlPlaneJoin_etcdCmd) carapace.Gen(join_phase_controlPlaneJoin_etcdCmd).FlagCompletion(carapace.ActionMap{ diff --git a/completers/kubeadm_completer/cmd/join_phase_controlPlaneJoin_markControlPlane.go b/completers/kubeadm_completer/cmd/join_phase_controlPlaneJoin_markControlPlane.go index 2b164af9..83456070 100644 --- a/completers/kubeadm_completer/cmd/join_phase_controlPlaneJoin_markControlPlane.go +++ b/completers/kubeadm_completer/cmd/join_phase_controlPlaneJoin_markControlPlane.go @@ -13,8 +13,10 @@ var join_phase_controlPlaneJoin_markControlPlaneCmd = &cobra.Command{ func init() { carapace.Gen(join_phase_controlPlaneJoin_markControlPlaneCmd).Standalone() - join_phase_controlPlaneJoin_markControlPlaneCmd.Flags().String("config", "", "Path to kubeadm config file.") + + join_phase_controlPlaneJoin_markControlPlaneCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") join_phase_controlPlaneJoin_markControlPlaneCmd.Flags().Bool("control-plane", false, "Create a new control plane instance on this node") + join_phase_controlPlaneJoin_markControlPlaneCmd.Flags().Bool("dry-run", false, "Don't apply any changes; just output what would be done.") join_phase_controlPlaneJoin_markControlPlaneCmd.Flags().String("node-name", "", "Specify the node name.") join_phase_controlPlaneJoinCmd.AddCommand(join_phase_controlPlaneJoin_markControlPlaneCmd) diff --git a/completers/kubeadm_completer/cmd/join_phase_controlPlaneJoin_updateStatus.go b/completers/kubeadm_completer/cmd/join_phase_controlPlaneJoin_updateStatus.go deleted file mode 100644 index c2b69b36..00000000 --- a/completers/kubeadm_completer/cmd/join_phase_controlPlaneJoin_updateStatus.go +++ /dev/null @@ -1,25 +0,0 @@ -package cmd - -import ( - "github.com/carapace-sh/carapace" - "github.com/spf13/cobra" -) - -var join_phase_controlPlaneJoin_updateStatusCmd = &cobra.Command{ - Use: "update-status", - Short: "Register the new control-plane node into the ClusterStatus maintained in the kubeadm-config ConfigMap (DEPRECATED)", - Run: func(cmd *cobra.Command, args []string) {}, -} - -func init() { - carapace.Gen(join_phase_controlPlaneJoin_updateStatusCmd).Standalone() - join_phase_controlPlaneJoin_updateStatusCmd.Flags().String("apiserver-advertise-address", "", "If the node should host a new control plane instance, the IP address the API Server will advertise it's listening on. If not set the default network interface will be used.") - join_phase_controlPlaneJoin_updateStatusCmd.Flags().String("config", "", "Path to kubeadm config file.") - join_phase_controlPlaneJoin_updateStatusCmd.Flags().Bool("control-plane", false, "Create a new control plane instance on this node") - join_phase_controlPlaneJoin_updateStatusCmd.Flags().String("node-name", "", "Specify the node name.") - join_phase_controlPlaneJoinCmd.AddCommand(join_phase_controlPlaneJoin_updateStatusCmd) - - carapace.Gen(join_phase_controlPlaneJoin_updateStatusCmd).FlagCompletion(carapace.ActionMap{ - "config": carapace.ActionFiles(), - }) -} diff --git a/completers/kubeadm_completer/cmd/join_phase_controlPlanePrepare.go b/completers/kubeadm_completer/cmd/join_phase_controlPlanePrepare.go index 3513b573..b3c558db 100644 --- a/completers/kubeadm_completer/cmd/join_phase_controlPlanePrepare.go +++ b/completers/kubeadm_completer/cmd/join_phase_controlPlanePrepare.go @@ -13,5 +13,6 @@ var join_phase_controlPlanePrepareCmd = &cobra.Command{ func init() { carapace.Gen(join_phase_controlPlanePrepareCmd).Standalone() + join_phaseCmd.AddCommand(join_phase_controlPlanePrepareCmd) } diff --git a/completers/kubeadm_completer/cmd/join_phase_controlPlanePrepare_all.go b/completers/kubeadm_completer/cmd/join_phase_controlPlanePrepare_all.go index a87fe12f..27eac0cb 100644 --- a/completers/kubeadm_completer/cmd/join_phase_controlPlanePrepare_all.go +++ b/completers/kubeadm_completer/cmd/join_phase_controlPlanePrepare_all.go @@ -6,24 +6,26 @@ import ( ) var join_phase_controlPlanePrepare_allCmd = &cobra.Command{ - Use: "all", + Use: "all [api-server-endpoint]", Short: "Prepare the machine for serving a control plane", Run: func(cmd *cobra.Command, args []string) {}, } func init() { carapace.Gen(join_phase_controlPlanePrepare_allCmd).Standalone() + join_phase_controlPlanePrepare_allCmd.Flags().String("apiserver-advertise-address", "", "If the node should host a new control plane instance, the IP address the API Server will advertise it's listening on. If not set the default network interface will be used.") - join_phase_controlPlanePrepare_allCmd.Flags().Int32("apiserver-bind-port", 6443, "If the node should host a new control plane instance, the port for the API Server to bind to.") - join_phase_controlPlanePrepare_allCmd.Flags().String("certificate-key", "", "Use this key to decrypt the certificate secrets uploaded by init.") - join_phase_controlPlanePrepare_allCmd.Flags().String("config", "", "Path to kubeadm config file.") + join_phase_controlPlanePrepare_allCmd.Flags().String("apiserver-bind-port", "", "If the node should host a new control plane instance, the port for the API Server to bind to.") + join_phase_controlPlanePrepare_allCmd.Flags().String("certificate-key", "", "Use this key to decrypt the certificate secrets uploaded by init. The certificate key is a hex encoded string that is an AES key of size 32 bytes.") + join_phase_controlPlanePrepare_allCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") join_phase_controlPlanePrepare_allCmd.Flags().Bool("control-plane", false, "Create a new control plane instance on this node") join_phase_controlPlanePrepare_allCmd.Flags().String("discovery-file", "", "For file-based discovery, a file or URL from which to load cluster information.") join_phase_controlPlanePrepare_allCmd.Flags().String("discovery-token", "", "For token-based discovery, the token used to validate cluster information fetched from the API server.") join_phase_controlPlanePrepare_allCmd.Flags().StringSlice("discovery-token-ca-cert-hash", []string{}, "For token-based discovery, validate that the root CA public key matches this hash (format: \":\").") join_phase_controlPlanePrepare_allCmd.Flags().Bool("discovery-token-unsafe-skip-ca-verification", false, "For token-based discovery, allow joining without --discovery-token-ca-cert-hash pinning.") + join_phase_controlPlanePrepare_allCmd.Flags().Bool("dry-run", false, "Don't apply any changes; just output what would be done.") join_phase_controlPlanePrepare_allCmd.Flags().String("node-name", "", "Specify the node name.") - join_phase_controlPlanePrepare_allCmd.Flags().String("patches", "", "Path to a directory that contains files named \"target[suffix][+patchtype].extension\".") + join_phase_controlPlanePrepare_allCmd.Flags().String("patches", "", "Path to a directory that contains files named \"target[suffix][+patchtype].extension\". For example, \"kube-apiserver0+merge.yaml\" or just \"etcd.json\". \"target\" can be one of \"kube-apiserver\", \"kube-controller-manager\", \"kube-scheduler\", \"etcd\", \"kubeletconfiguration\", \"corednsdeployment\". \"patchtype\" can be one of \"strategic\", \"merge\" or \"json\" and they match the patch formats supported by kubectl. The default \"patchtype\" is \"strategic\". \"extension\" must be either \"json\" or \"yaml\". \"suffix\" is an optional string that can be used to determine which patches are applied first alpha-numerically.") join_phase_controlPlanePrepare_allCmd.Flags().String("tls-bootstrap-token", "", "Specify the token used to temporarily authenticate with the Kubernetes Control Plane while joining the node.") join_phase_controlPlanePrepare_allCmd.Flags().String("token", "", "Use this token for both discovery-token and tls-bootstrap-token when those values are not provided.") join_phase_controlPlanePrepareCmd.AddCommand(join_phase_controlPlanePrepare_allCmd) diff --git a/completers/kubeadm_completer/cmd/join_phase_controlPlanePrepare_certs.go b/completers/kubeadm_completer/cmd/join_phase_controlPlanePrepare_certs.go index 7af3c769..d3a1ee05 100644 --- a/completers/kubeadm_completer/cmd/join_phase_controlPlanePrepare_certs.go +++ b/completers/kubeadm_completer/cmd/join_phase_controlPlanePrepare_certs.go @@ -6,20 +6,22 @@ import ( ) var join_phase_controlPlanePrepare_certsCmd = &cobra.Command{ - Use: "certs", + Use: "certs [api-server-endpoint]", Short: "Generate the certificates for the new control plane components", Run: func(cmd *cobra.Command, args []string) {}, } func init() { carapace.Gen(join_phase_controlPlanePrepare_certsCmd).Standalone() + join_phase_controlPlanePrepare_certsCmd.Flags().String("apiserver-advertise-address", "", "If the node should host a new control plane instance, the IP address the API Server will advertise it's listening on. If not set the default network interface will be used.") - join_phase_controlPlanePrepare_certsCmd.Flags().String("config", "", "Path to kubeadm config file.") + join_phase_controlPlanePrepare_certsCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") join_phase_controlPlanePrepare_certsCmd.Flags().Bool("control-plane", false, "Create a new control plane instance on this node") join_phase_controlPlanePrepare_certsCmd.Flags().String("discovery-file", "", "For file-based discovery, a file or URL from which to load cluster information.") join_phase_controlPlanePrepare_certsCmd.Flags().String("discovery-token", "", "For token-based discovery, the token used to validate cluster information fetched from the API server.") join_phase_controlPlanePrepare_certsCmd.Flags().StringSlice("discovery-token-ca-cert-hash", []string{}, "For token-based discovery, validate that the root CA public key matches this hash (format: \":\").") join_phase_controlPlanePrepare_certsCmd.Flags().Bool("discovery-token-unsafe-skip-ca-verification", false, "For token-based discovery, allow joining without --discovery-token-ca-cert-hash pinning.") + join_phase_controlPlanePrepare_certsCmd.Flags().Bool("dry-run", false, "Don't apply any changes; just output what would be done.") join_phase_controlPlanePrepare_certsCmd.Flags().String("node-name", "", "Specify the node name.") join_phase_controlPlanePrepare_certsCmd.Flags().String("tls-bootstrap-token", "", "Specify the token used to temporarily authenticate with the Kubernetes Control Plane while joining the node.") join_phase_controlPlanePrepare_certsCmd.Flags().String("token", "", "Use this token for both discovery-token and tls-bootstrap-token when those values are not provided.") diff --git a/completers/kubeadm_completer/cmd/join_phase_controlPlanePrepare_controlPlane.go b/completers/kubeadm_completer/cmd/join_phase_controlPlanePrepare_controlPlane.go index ebb524bc..912f7b3d 100644 --- a/completers/kubeadm_completer/cmd/join_phase_controlPlanePrepare_controlPlane.go +++ b/completers/kubeadm_completer/cmd/join_phase_controlPlanePrepare_controlPlane.go @@ -13,11 +13,13 @@ var join_phase_controlPlanePrepare_controlPlaneCmd = &cobra.Command{ func init() { carapace.Gen(join_phase_controlPlanePrepare_controlPlaneCmd).Standalone() + join_phase_controlPlanePrepare_controlPlaneCmd.Flags().String("apiserver-advertise-address", "", "If the node should host a new control plane instance, the IP address the API Server will advertise it's listening on. If not set the default network interface will be used.") - join_phase_controlPlanePrepare_controlPlaneCmd.Flags().Int32("apiserver-bind-port", 6443, "If the node should host a new control plane instance, the port for the API Server to bind to.") - join_phase_controlPlanePrepare_controlPlaneCmd.Flags().String("config", "", "Path to kubeadm config file.") + join_phase_controlPlanePrepare_controlPlaneCmd.Flags().String("apiserver-bind-port", "", "If the node should host a new control plane instance, the port for the API Server to bind to.") + join_phase_controlPlanePrepare_controlPlaneCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") join_phase_controlPlanePrepare_controlPlaneCmd.Flags().Bool("control-plane", false, "Create a new control plane instance on this node") - join_phase_controlPlanePrepare_controlPlaneCmd.Flags().String("patches", "", "Path to a directory that contains files named \"target[suffix][+patchtype].extension\".") + join_phase_controlPlanePrepare_controlPlaneCmd.Flags().Bool("dry-run", false, "Don't apply any changes; just output what would be done.") + join_phase_controlPlanePrepare_controlPlaneCmd.Flags().String("patches", "", "Path to a directory that contains files named \"target[suffix][+patchtype].extension\". For example, \"kube-apiserver0+merge.yaml\" or just \"etcd.json\". \"target\" can be one of \"kube-apiserver\", \"kube-controller-manager\", \"kube-scheduler\", \"etcd\", \"kubeletconfiguration\", \"corednsdeployment\". \"patchtype\" can be one of \"strategic\", \"merge\" or \"json\" and they match the patch formats supported by kubectl. The default \"patchtype\" is \"strategic\". \"extension\" must be either \"json\" or \"yaml\". \"suffix\" is an optional string that can be used to determine which patches are applied first alpha-numerically.") join_phase_controlPlanePrepareCmd.AddCommand(join_phase_controlPlanePrepare_controlPlaneCmd) carapace.Gen(join_phase_controlPlanePrepare_controlPlaneCmd).FlagCompletion(carapace.ActionMap{ diff --git a/completers/kubeadm_completer/cmd/join_phase_controlPlanePrepare_downloadCerts.go b/completers/kubeadm_completer/cmd/join_phase_controlPlanePrepare_downloadCerts.go index 3ea15f8c..b2f4dff3 100644 --- a/completers/kubeadm_completer/cmd/join_phase_controlPlanePrepare_downloadCerts.go +++ b/completers/kubeadm_completer/cmd/join_phase_controlPlanePrepare_downloadCerts.go @@ -6,20 +6,22 @@ import ( ) var join_phase_controlPlanePrepare_downloadCertsCmd = &cobra.Command{ - Use: "download-certs", - Short: "[EXPERIMENTAL] Download certificates shared among control-plane nodes from the kubeadm-certs Secret", + Use: "download-certs [api-server-endpoint]", + Short: "Download certificates shared among control-plane nodes from the kubeadm-certs Secret", Run: func(cmd *cobra.Command, args []string) {}, } func init() { carapace.Gen(join_phase_controlPlanePrepare_downloadCertsCmd).Standalone() - join_phase_controlPlanePrepare_downloadCertsCmd.Flags().String("certificate-key", "", "Use this key to decrypt the certificate secrets uploaded by init.") - join_phase_controlPlanePrepare_downloadCertsCmd.Flags().String("config", "", "Path to kubeadm config file.") + + join_phase_controlPlanePrepare_downloadCertsCmd.Flags().String("certificate-key", "", "Use this key to decrypt the certificate secrets uploaded by init. The certificate key is a hex encoded string that is an AES key of size 32 bytes.") + join_phase_controlPlanePrepare_downloadCertsCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") join_phase_controlPlanePrepare_downloadCertsCmd.Flags().Bool("control-plane", false, "Create a new control plane instance on this node") join_phase_controlPlanePrepare_downloadCertsCmd.Flags().String("discovery-file", "", "For file-based discovery, a file or URL from which to load cluster information.") join_phase_controlPlanePrepare_downloadCertsCmd.Flags().String("discovery-token", "", "For token-based discovery, the token used to validate cluster information fetched from the API server.") join_phase_controlPlanePrepare_downloadCertsCmd.Flags().StringSlice("discovery-token-ca-cert-hash", []string{}, "For token-based discovery, validate that the root CA public key matches this hash (format: \":\").") join_phase_controlPlanePrepare_downloadCertsCmd.Flags().Bool("discovery-token-unsafe-skip-ca-verification", false, "For token-based discovery, allow joining without --discovery-token-ca-cert-hash pinning.") + join_phase_controlPlanePrepare_downloadCertsCmd.Flags().Bool("dry-run", false, "Don't apply any changes; just output what would be done.") join_phase_controlPlanePrepare_downloadCertsCmd.Flags().String("tls-bootstrap-token", "", "Specify the token used to temporarily authenticate with the Kubernetes Control Plane while joining the node.") join_phase_controlPlanePrepare_downloadCertsCmd.Flags().String("token", "", "Use this token for both discovery-token and tls-bootstrap-token when those values are not provided.") join_phase_controlPlanePrepareCmd.AddCommand(join_phase_controlPlanePrepare_downloadCertsCmd) diff --git a/completers/kubeadm_completer/cmd/join_phase_controlPlanePrepare_kubeconfig.go b/completers/kubeadm_completer/cmd/join_phase_controlPlanePrepare_kubeconfig.go index 6398def9..bea8537c 100644 --- a/completers/kubeadm_completer/cmd/join_phase_controlPlanePrepare_kubeconfig.go +++ b/completers/kubeadm_completer/cmd/join_phase_controlPlanePrepare_kubeconfig.go @@ -6,20 +6,22 @@ import ( ) var join_phase_controlPlanePrepare_kubeconfigCmd = &cobra.Command{ - Use: "kubeconfig", + Use: "kubeconfig [api-server-endpoint]", Short: "Generate the kubeconfig for the new control plane components", Run: func(cmd *cobra.Command, args []string) {}, } func init() { carapace.Gen(join_phase_controlPlanePrepare_kubeconfigCmd).Standalone() - join_phase_controlPlanePrepare_kubeconfigCmd.Flags().String("certificate-key", "", "Use this key to decrypt the certificate secrets uploaded by init.") - join_phase_controlPlanePrepare_kubeconfigCmd.Flags().String("config", "", "Path to kubeadm config file.") + + join_phase_controlPlanePrepare_kubeconfigCmd.Flags().String("certificate-key", "", "Use this key to decrypt the certificate secrets uploaded by init. The certificate key is a hex encoded string that is an AES key of size 32 bytes.") + join_phase_controlPlanePrepare_kubeconfigCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") join_phase_controlPlanePrepare_kubeconfigCmd.Flags().Bool("control-plane", false, "Create a new control plane instance on this node") join_phase_controlPlanePrepare_kubeconfigCmd.Flags().String("discovery-file", "", "For file-based discovery, a file or URL from which to load cluster information.") join_phase_controlPlanePrepare_kubeconfigCmd.Flags().String("discovery-token", "", "For token-based discovery, the token used to validate cluster information fetched from the API server.") join_phase_controlPlanePrepare_kubeconfigCmd.Flags().StringSlice("discovery-token-ca-cert-hash", []string{}, "For token-based discovery, validate that the root CA public key matches this hash (format: \":\").") join_phase_controlPlanePrepare_kubeconfigCmd.Flags().Bool("discovery-token-unsafe-skip-ca-verification", false, "For token-based discovery, allow joining without --discovery-token-ca-cert-hash pinning.") + join_phase_controlPlanePrepare_kubeconfigCmd.Flags().Bool("dry-run", false, "Don't apply any changes; just output what would be done.") join_phase_controlPlanePrepare_kubeconfigCmd.Flags().String("tls-bootstrap-token", "", "Specify the token used to temporarily authenticate with the Kubernetes Control Plane while joining the node.") join_phase_controlPlanePrepare_kubeconfigCmd.Flags().String("token", "", "Use this token for both discovery-token and tls-bootstrap-token when those values are not provided.") join_phase_controlPlanePrepareCmd.AddCommand(join_phase_controlPlanePrepare_kubeconfigCmd) diff --git a/completers/kubeadm_completer/cmd/join_phase_kubeletStart.go b/completers/kubeadm_completer/cmd/join_phase_kubeletStart.go index 5418c811..7e8e1d31 100644 --- a/completers/kubeadm_completer/cmd/join_phase_kubeletStart.go +++ b/completers/kubeadm_completer/cmd/join_phase_kubeletStart.go @@ -6,20 +6,23 @@ import ( ) var join_phase_kubeletStartCmd = &cobra.Command{ - Use: "kubelet-start", + Use: "kubelet-start [api-server-endpoint]", Short: "Write kubelet settings, certificates and (re)start the kubelet", Run: func(cmd *cobra.Command, args []string) {}, } func init() { carapace.Gen(join_phase_kubeletStartCmd).Standalone() - join_phase_kubeletStartCmd.Flags().String("config", "", "Path to kubeadm config file.") + + join_phase_kubeletStartCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") join_phase_kubeletStartCmd.Flags().String("cri-socket", "", "Path to the CRI socket to connect. If empty kubeadm will try to auto-detect this value; use this option only if you have more than one CRI installed or if you have non-standard CRI socket.") join_phase_kubeletStartCmd.Flags().String("discovery-file", "", "For file-based discovery, a file or URL from which to load cluster information.") join_phase_kubeletStartCmd.Flags().String("discovery-token", "", "For token-based discovery, the token used to validate cluster information fetched from the API server.") join_phase_kubeletStartCmd.Flags().StringSlice("discovery-token-ca-cert-hash", []string{}, "For token-based discovery, validate that the root CA public key matches this hash (format: \":\").") join_phase_kubeletStartCmd.Flags().Bool("discovery-token-unsafe-skip-ca-verification", false, "For token-based discovery, allow joining without --discovery-token-ca-cert-hash pinning.") + join_phase_kubeletStartCmd.Flags().Bool("dry-run", false, "Don't apply any changes; just output what would be done.") join_phase_kubeletStartCmd.Flags().String("node-name", "", "Specify the node name.") + join_phase_kubeletStartCmd.Flags().String("patches", "", "Path to a directory that contains files named \"target[suffix][+patchtype].extension\". For example, \"kube-apiserver0+merge.yaml\" or just \"etcd.json\". \"target\" can be one of \"kube-apiserver\", \"kube-controller-manager\", \"kube-scheduler\", \"etcd\", \"kubeletconfiguration\", \"corednsdeployment\". \"patchtype\" can be one of \"strategic\", \"merge\" or \"json\" and they match the patch formats supported by kubectl. The default \"patchtype\" is \"strategic\". \"extension\" must be either \"json\" or \"yaml\". \"suffix\" is an optional string that can be used to determine which patches are applied first alpha-numerically.") join_phase_kubeletStartCmd.Flags().String("tls-bootstrap-token", "", "Specify the token used to temporarily authenticate with the Kubernetes Control Plane while joining the node.") join_phase_kubeletStartCmd.Flags().String("token", "", "Use this token for both discovery-token and tls-bootstrap-token when those values are not provided.") join_phaseCmd.AddCommand(join_phase_kubeletStartCmd) diff --git a/completers/kubeadm_completer/cmd/join_phase_preflight.go b/completers/kubeadm_completer/cmd/join_phase_preflight.go index f1de194d..ae39ed06 100644 --- a/completers/kubeadm_completer/cmd/join_phase_preflight.go +++ b/completers/kubeadm_completer/cmd/join_phase_preflight.go @@ -7,23 +7,25 @@ import ( ) var join_phase_preflightCmd = &cobra.Command{ - Use: "preflight", + Use: "preflight [api-server-endpoint]", Short: "Run join pre-flight checks", Run: func(cmd *cobra.Command, args []string) {}, } func init() { carapace.Gen(join_phase_preflightCmd).Standalone() + join_phase_preflightCmd.Flags().String("apiserver-advertise-address", "", "If the node should host a new control plane instance, the IP address the API Server will advertise it's listening on. If not set the default network interface will be used.") - join_phase_preflightCmd.Flags().Int32("apiserver-bind-port", 6443, "If the node should host a new control plane instance, the port for the API Server to bind to.") - join_phase_preflightCmd.Flags().String("certificate-key", "", "Use this key to decrypt the certificate secrets uploaded by init.") - join_phase_preflightCmd.Flags().String("config", "", "Path to kubeadm config file.") + join_phase_preflightCmd.Flags().String("apiserver-bind-port", "", "If the node should host a new control plane instance, the port for the API Server to bind to.") + join_phase_preflightCmd.Flags().String("certificate-key", "", "Use this key to decrypt the certificate secrets uploaded by init. The certificate key is a hex encoded string that is an AES key of size 32 bytes.") + join_phase_preflightCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") join_phase_preflightCmd.Flags().Bool("control-plane", false, "Create a new control plane instance on this node") join_phase_preflightCmd.Flags().String("cri-socket", "", "Path to the CRI socket to connect. If empty kubeadm will try to auto-detect this value; use this option only if you have more than one CRI installed or if you have non-standard CRI socket.") join_phase_preflightCmd.Flags().String("discovery-file", "", "For file-based discovery, a file or URL from which to load cluster information.") join_phase_preflightCmd.Flags().String("discovery-token", "", "For token-based discovery, the token used to validate cluster information fetched from the API server.") join_phase_preflightCmd.Flags().StringSlice("discovery-token-ca-cert-hash", []string{}, "For token-based discovery, validate that the root CA public key matches this hash (format: \":\").") join_phase_preflightCmd.Flags().Bool("discovery-token-unsafe-skip-ca-verification", false, "For token-based discovery, allow joining without --discovery-token-ca-cert-hash pinning.") + join_phase_preflightCmd.Flags().Bool("dry-run", false, "Don't apply any changes; just output what would be done.") join_phase_preflightCmd.Flags().StringSlice("ignore-preflight-errors", []string{}, "A list of checks whose errors will be shown as warnings. Example: 'IsPrivilegedUser,Swap'. Value 'all' ignores errors from all checks.") join_phase_preflightCmd.Flags().String("node-name", "", "Specify the node name.") join_phase_preflightCmd.Flags().String("tls-bootstrap-token", "", "Specify the token used to temporarily authenticate with the Kubernetes Control Plane while joining the node.") diff --git a/completers/kubeadm_completer/cmd/join_phase_waitControlPlane.go b/completers/kubeadm_completer/cmd/join_phase_waitControlPlane.go new file mode 100644 index 00000000..130eddb7 --- /dev/null +++ b/completers/kubeadm_completer/cmd/join_phase_waitControlPlane.go @@ -0,0 +1,18 @@ +package cmd + +import ( + "github.com/carapace-sh/carapace" + "github.com/spf13/cobra" +) + +var join_phase_waitControlPlaneCmd = &cobra.Command{ + Use: "wait-control-plane", + Short: "EXPERIMENTAL: Wait for the control plane to start", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(join_phase_waitControlPlaneCmd).Standalone() + + join_phaseCmd.AddCommand(join_phase_waitControlPlaneCmd) +} diff --git a/completers/kubeadm_completer/cmd/kubeconfig.go b/completers/kubeadm_completer/cmd/kubeconfig.go index 418f48d3..99e53512 100644 --- a/completers/kubeadm_completer/cmd/kubeconfig.go +++ b/completers/kubeadm_completer/cmd/kubeconfig.go @@ -13,5 +13,6 @@ var kubeconfigCmd = &cobra.Command{ func init() { carapace.Gen(kubeconfigCmd).Standalone() + rootCmd.AddCommand(kubeconfigCmd) } diff --git a/completers/kubeadm_completer/cmd/kubeconfig_user.go b/completers/kubeadm_completer/cmd/kubeconfig_user.go index f9fcc6b4..a1f98c9f 100644 --- a/completers/kubeadm_completer/cmd/kubeconfig_user.go +++ b/completers/kubeadm_completer/cmd/kubeconfig_user.go @@ -13,11 +13,13 @@ var kubeconfig_userCmd = &cobra.Command{ func init() { carapace.Gen(kubeconfig_userCmd).Standalone() + kubeconfig_userCmd.Flags().String("client-name", "", "The name of user. It will be used as the CN if client certificates are created") kubeconfig_userCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") - kubeconfig_userCmd.Flags().StringSlice("org", []string{}, "The orgnizations of the client certificate. It will be used as the O if client certificates are created") + kubeconfig_userCmd.Flags().StringSlice("org", []string{}, "The organizations of the client certificate. It will be used as the O if client certificates are created") kubeconfig_userCmd.Flags().String("token", "", "The token that should be used as the authentication mechanism for this kubeconfig, instead of client certificates") kubeconfig_userCmd.Flags().String("validity-period", "", "The validity period of the client certificate. It is an offset from the current time.") + kubeconfig_userCmd.MarkFlagRequired("client-name") kubeconfigCmd.AddCommand(kubeconfig_userCmd) carapace.Gen(kubeconfig_userCmd).FlagCompletion(carapace.ActionMap{ diff --git a/completers/kubeadm_completer/cmd/reset.go b/completers/kubeadm_completer/cmd/reset.go index bd52b5ab..51a2c2b5 100644 --- a/completers/kubeadm_completer/cmd/reset.go +++ b/completers/kubeadm_completer/cmd/reset.go @@ -14,11 +14,15 @@ var resetCmd = &cobra.Command{ func init() { carapace.Gen(resetCmd).Standalone() - resetCmd.Flags().String("cert-dir", "/etc/kubernetes/pki", "The path to the directory where the certificates are stored. If specified, clean this directory.") + + resetCmd.Flags().String("cert-dir", "", "The path to the directory where the certificates are stored. If specified, clean this directory.") + resetCmd.Flags().Bool("cleanup-tmp-dir", false, "Cleanup the \"/etc/kubernetes/tmp\" directory") + resetCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") resetCmd.Flags().String("cri-socket", "", "Path to the CRI socket to connect. If empty kubeadm will try to auto-detect this value; use this option only if you have more than one CRI installed or if you have non-standard CRI socket.") + resetCmd.Flags().Bool("dry-run", false, "Don't apply any changes; just output what would be done.") resetCmd.Flags().BoolP("force", "f", false, "Reset the node without prompting for confirmation.") resetCmd.Flags().StringSlice("ignore-preflight-errors", []string{}, "A list of checks whose errors will be shown as warnings. Example: 'IsPrivilegedUser,Swap'. Value 'all' ignores errors from all checks.") - resetCmd.Flags().String("kubeconfig", "/etc/kubernetes/admin.conf", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") + resetCmd.Flags().String("kubeconfig", "", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") resetCmd.Flags().StringSlice("skip-phases", []string{}, "List of phases to be skipped") rootCmd.AddCommand(resetCmd) diff --git a/completers/kubeadm_completer/cmd/reset_phase.go b/completers/kubeadm_completer/cmd/reset_phase.go index 9ee9ba21..27ee1cf7 100644 --- a/completers/kubeadm_completer/cmd/reset_phase.go +++ b/completers/kubeadm_completer/cmd/reset_phase.go @@ -7,11 +7,12 @@ import ( var reset_phaseCmd = &cobra.Command{ Use: "phase", - Short: "Use this command to invoke single phase of the reset workflow", + Short: "Use this command to invoke single phase of the \"reset\" workflow", Run: func(cmd *cobra.Command, args []string) {}, } func init() { carapace.Gen(reset_phaseCmd).Standalone() + resetCmd.AddCommand(reset_phaseCmd) } diff --git a/completers/kubeadm_completer/cmd/reset_phase_cleanupNode.go b/completers/kubeadm_completer/cmd/reset_phase_cleanupNode.go index 14468f79..74b8b1e1 100644 --- a/completers/kubeadm_completer/cmd/reset_phase_cleanupNode.go +++ b/completers/kubeadm_completer/cmd/reset_phase_cleanupNode.go @@ -6,15 +6,19 @@ import ( ) var reset_phase_cleanupNodeCmd = &cobra.Command{ - Use: "cleanup-node", - Short: "Run cleanup node.", - Run: func(cmd *cobra.Command, args []string) {}, + Use: "cleanup-node", + Short: "Run cleanup node.", + Aliases: []string{"cleanupnode"}, + Run: func(cmd *cobra.Command, args []string) {}, } func init() { carapace.Gen(reset_phase_cleanupNodeCmd).Standalone() - reset_phase_cleanupNodeCmd.Flags().String("cert-dir", "/etc/kubernetes/pki", "The path to the directory where the certificates are stored. If specified, clean this directory.") + + reset_phase_cleanupNodeCmd.Flags().String("cert-dir", "", "The path to the directory where the certificates are stored. If specified, clean this directory.") + reset_phase_cleanupNodeCmd.Flags().Bool("cleanup-tmp-dir", false, "Cleanup the \"/etc/kubernetes/tmp\" directory") reset_phase_cleanupNodeCmd.Flags().String("cri-socket", "", "Path to the CRI socket to connect. If empty kubeadm will try to auto-detect this value; use this option only if you have more than one CRI installed or if you have non-standard CRI socket.") + reset_phase_cleanupNodeCmd.Flags().Bool("dry-run", false, "Don't apply any changes; just output what would be done.") reset_phaseCmd.AddCommand(reset_phase_cleanupNodeCmd) carapace.Gen(reset_phase_cleanupNodeCmd).FlagCompletion(carapace.ActionMap{ diff --git a/completers/kubeadm_completer/cmd/reset_phase_preflight.go b/completers/kubeadm_completer/cmd/reset_phase_preflight.go index 09deb9ed..0fc5cd15 100644 --- a/completers/kubeadm_completer/cmd/reset_phase_preflight.go +++ b/completers/kubeadm_completer/cmd/reset_phase_preflight.go @@ -7,13 +7,16 @@ import ( ) var reset_phase_preflightCmd = &cobra.Command{ - Use: "preflight", - Short: "Run reset pre-flight checks", - Run: func(cmd *cobra.Command, args []string) {}, + Use: "preflight", + Short: "Run reset pre-flight checks", + Aliases: []string{"pre-flight"}, + Run: func(cmd *cobra.Command, args []string) {}, } func init() { carapace.Gen(reset_phase_preflightCmd).Standalone() + + reset_phase_preflightCmd.Flags().Bool("dry-run", false, "Don't apply any changes; just output what would be done.") reset_phase_preflightCmd.Flags().BoolP("force", "f", false, "Reset the node without prompting for confirmation.") reset_phase_preflightCmd.Flags().StringSlice("ignore-preflight-errors", []string{}, "A list of checks whose errors will be shown as warnings. Example: 'IsPrivilegedUser,Swap'. Value 'all' ignores errors from all checks.") reset_phaseCmd.AddCommand(reset_phase_preflightCmd) diff --git a/completers/kubeadm_completer/cmd/reset_phase_removeEtcdMember.go b/completers/kubeadm_completer/cmd/reset_phase_removeEtcdMember.go index e8fba4c9..ffd04819 100644 --- a/completers/kubeadm_completer/cmd/reset_phase_removeEtcdMember.go +++ b/completers/kubeadm_completer/cmd/reset_phase_removeEtcdMember.go @@ -13,7 +13,9 @@ var reset_phase_removeEtcdMemberCmd = &cobra.Command{ func init() { carapace.Gen(reset_phase_removeEtcdMemberCmd).Standalone() - reset_phase_removeEtcdMemberCmd.Flags().String("kubeconfig", "/etc/kubernetes/admin.conf", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") + + reset_phase_removeEtcdMemberCmd.Flags().Bool("dry-run", false, "Don't apply any changes; just output what would be done.") + reset_phase_removeEtcdMemberCmd.Flags().String("kubeconfig", "", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") reset_phaseCmd.AddCommand(reset_phase_removeEtcdMemberCmd) carapace.Gen(reset_phase_removeEtcdMemberCmd).FlagCompletion(carapace.ActionMap{ diff --git a/completers/kubeadm_completer/cmd/reset_phase_updateClusterStatus.go b/completers/kubeadm_completer/cmd/reset_phase_updateClusterStatus.go deleted file mode 100644 index 30c64ab2..00000000 --- a/completers/kubeadm_completer/cmd/reset_phase_updateClusterStatus.go +++ /dev/null @@ -1,17 +0,0 @@ -package cmd - -import ( - "github.com/carapace-sh/carapace" - "github.com/spf13/cobra" -) - -var reset_phase_updateClusterStatusCmd = &cobra.Command{ - Use: "update-cluster-status", - Short: "Remove this node from the ClusterStatus object (DEPRECATED).", - Run: func(cmd *cobra.Command, args []string) {}, -} - -func init() { - carapace.Gen(reset_phase_updateClusterStatusCmd).Standalone() - reset_phaseCmd.AddCommand(reset_phase_updateClusterStatusCmd) -} diff --git a/completers/kubeadm_completer/cmd/root.go b/completers/kubeadm_completer/cmd/root.go index 862d8dc3..07a7da9e 100644 --- a/completers/kubeadm_completer/cmd/root.go +++ b/completers/kubeadm_completer/cmd/root.go @@ -26,7 +26,7 @@ func init() { rootCmd.PersistentFlags().Uint64("log-file-max-size", 1800, "Defines the maximum size a log file can grow to. Unit is megabytes. If the value is 0, the maximum file size is unlimited.") rootCmd.PersistentFlags().Bool("logtostderr", true, "log to standard error instead of files") rootCmd.PersistentFlags().Bool("one-output", false, "If true, only write logs to their native severity level (vs also writing to each lower severity level)") - rootCmd.PersistentFlags().String("rootfs", "", "[EXPERIMENTAL] The path to the 'real' host root filesystem.") + rootCmd.PersistentFlags().String("rootfs", "", "The path to the 'real' host root filesystem. This will cause kubeadm to chroot into the provided path.") rootCmd.PersistentFlags().Bool("skip-headers", false, "If true, avoid header prefixes in the log messages") rootCmd.PersistentFlags().Bool("skip-log-headers", false, "If true, avoid headers when opening log files") rootCmd.PersistentFlags().String("stderrthreshold", "", "logs at or above this threshold go to stderr") diff --git a/completers/kubeadm_completer/cmd/token.go b/completers/kubeadm_completer/cmd/token.go index ef5bef58..60394ac3 100644 --- a/completers/kubeadm_completer/cmd/token.go +++ b/completers/kubeadm_completer/cmd/token.go @@ -13,6 +13,7 @@ var tokenCmd = &cobra.Command{ func init() { carapace.Gen(tokenCmd).Standalone() + tokenCmd.PersistentFlags().Bool("dry-run", false, "Whether to enable dry-run mode or not") tokenCmd.PersistentFlags().String("kubeconfig", "", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") rootCmd.AddCommand(tokenCmd) diff --git a/completers/kubeadm_completer/cmd/token_create.go b/completers/kubeadm_completer/cmd/token_create.go index 825ebaf4..fa88a886 100644 --- a/completers/kubeadm_completer/cmd/token_create.go +++ b/completers/kubeadm_completer/cmd/token_create.go @@ -6,20 +6,21 @@ import ( ) var token_createCmd = &cobra.Command{ - Use: "create", + Use: "create [token]", Short: "Create bootstrap tokens on the server", Run: func(cmd *cobra.Command, args []string) {}, } func init() { carapace.Gen(token_createCmd).Standalone() + token_createCmd.Flags().String("certificate-key", "", "When used together with '--print-join-command', print the full 'kubeadm join' flag needed to join the cluster as a control-plane. To create a new certificate key you must use 'kubeadm init phase upload-certs --upload-certs'.") token_createCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") token_createCmd.Flags().String("description", "", "A human friendly description of how this token is used.") - token_createCmd.Flags().StringSlice("groups", []string{"system:bootstrappers:kubeadm:default-node-token"}, "Extra groups that this token will authenticate as when used for authentication. Must match \"\\Asystem:bootstrappers:[a-z0-9:-]{0,255}[a-z0-9]\\z\"") + token_createCmd.Flags().StringSlice("groups", []string{}, "Extra groups that this token will authenticate as when used for authentication. Must match \"\\Asystem:bootstrappers:[a-z0-9:-]{0,255}[a-z0-9]\\z\"") token_createCmd.Flags().Bool("print-join-command", false, "Instead of printing only the token, print the full 'kubeadm join' flag needed to join the cluster using the token.") token_createCmd.Flags().String("ttl", "", "The duration before the token is automatically deleted (e.g. 1s, 2m, 3h). If set to '0', the token will never expire") - token_createCmd.Flags().StringSlice("usages", []string{"signing", "authentication"}, "Describes the ways in which this token can be used. You can pass --usages multiple times or provide a comma separated list of options. Valid options: [signing,authentication]") + token_createCmd.Flags().StringSlice("usages", []string{}, "Describes the ways in which this token can be used. You can pass --usages multiple times or provide a comma separated list of options. Valid options: [signing,authentication]") tokenCmd.AddCommand(token_createCmd) carapace.Gen(token_createCmd).FlagCompletion(carapace.ActionMap{ diff --git a/completers/kubeadm_completer/cmd/token_delete.go b/completers/kubeadm_completer/cmd/token_delete.go index 94fff70d..0b02efd2 100644 --- a/completers/kubeadm_completer/cmd/token_delete.go +++ b/completers/kubeadm_completer/cmd/token_delete.go @@ -6,12 +6,13 @@ import ( ) var token_deleteCmd = &cobra.Command{ - Use: "delete", + Use: "delete [token-value] ...", Short: "Delete bootstrap tokens on the server", Run: func(cmd *cobra.Command, args []string) {}, } func init() { carapace.Gen(token_deleteCmd).Standalone() + tokenCmd.AddCommand(token_deleteCmd) } diff --git a/completers/kubeadm_completer/cmd/token_generate.go b/completers/kubeadm_completer/cmd/token_generate.go index 2d2ab35d..073ea796 100644 --- a/completers/kubeadm_completer/cmd/token_generate.go +++ b/completers/kubeadm_completer/cmd/token_generate.go @@ -13,5 +13,6 @@ var token_generateCmd = &cobra.Command{ func init() { carapace.Gen(token_generateCmd).Standalone() + tokenCmd.AddCommand(token_generateCmd) } diff --git a/completers/kubeadm_completer/cmd/token_list.go b/completers/kubeadm_completer/cmd/token_list.go index 9036d31a..5c695b17 100644 --- a/completers/kubeadm_completer/cmd/token_list.go +++ b/completers/kubeadm_completer/cmd/token_list.go @@ -2,6 +2,7 @@ package cmd import ( "github.com/carapace-sh/carapace" + "github.com/carapace-sh/carapace-bin/pkg/actions/tools/kubeadm" "github.com/spf13/cobra" ) @@ -13,12 +14,13 @@ var token_listCmd = &cobra.Command{ func init() { carapace.Gen(token_listCmd).Standalone() - token_listCmd.Flags().Bool("allow-missing-template-keys", true, "If true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats.") - token_listCmd.Flags().StringP("experimental-output", "o", "text", "Output format. One of: text|json|yaml|go-template|go-template-file|template|templatefile|jsonpath|jsonpath-as-json|jsonpath-file.") + + token_listCmd.Flags().Bool("allow-missing-template-keys", false, "If true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats.") + token_listCmd.Flags().StringP("output", "o", "", "Output format. One of: text|json|yaml|go-template|go-template-file|template|templatefile|jsonpath|jsonpath-as-json|jsonpath-file.") token_listCmd.Flags().Bool("show-managed-fields", false, "If true, keep the managedFields when printing objects in JSON or YAML format.") tokenCmd.AddCommand(token_listCmd) carapace.Gen(token_listCmd).FlagCompletion(carapace.ActionMap{ - "experimental-output": carapace.ActionValues("text", "json", "yaml", "go-template", "go-template-file", "template", "templatefile", "jsonpath", "jsonpath-as-json", "jsonpath-file"), + "output": kubeadm.ActionOutputFormats(), }) } diff --git a/completers/kubeadm_completer/cmd/upgrade.go b/completers/kubeadm_completer/cmd/upgrade.go index 9179288f..34bbf638 100644 --- a/completers/kubeadm_completer/cmd/upgrade.go +++ b/completers/kubeadm_completer/cmd/upgrade.go @@ -13,5 +13,6 @@ var upgradeCmd = &cobra.Command{ func init() { carapace.Gen(upgradeCmd).Standalone() + rootCmd.AddCommand(upgradeCmd) } diff --git a/completers/kubeadm_completer/cmd/upgrade_apply.go b/completers/kubeadm_completer/cmd/upgrade_apply.go index 97417376..5ba00023 100644 --- a/completers/kubeadm_completer/cmd/upgrade_apply.go +++ b/completers/kubeadm_completer/cmd/upgrade_apply.go @@ -7,25 +7,26 @@ import ( ) var upgrade_applyCmd = &cobra.Command{ - Use: "apply", + Use: "apply [version]", Short: "Upgrade your Kubernetes cluster to the specified version", Run: func(cmd *cobra.Command, args []string) {}, } func init() { carapace.Gen(upgrade_applyCmd).Standalone() + upgrade_applyCmd.Flags().Bool("allow-experimental-upgrades", false, "Show unstable versions of Kubernetes as an upgrade alternative and allow upgrading to an alpha/beta/release candidate versions of Kubernetes.") upgrade_applyCmd.Flags().Bool("allow-release-candidate-upgrades", false, "Show release candidate versions of Kubernetes as an upgrade alternative and allow upgrading to a release candidate versions of Kubernetes.") - upgrade_applyCmd.Flags().Bool("certificate-renewal", true, "Perform the renewal of certificates used by component changed during upgrades.") + upgrade_applyCmd.Flags().Bool("certificate-renewal", false, "Perform the renewal of certificates used by component changed during upgrades.") upgrade_applyCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") upgrade_applyCmd.Flags().Bool("dry-run", false, "Do not change any state, just output what actions would be performed.") - upgrade_applyCmd.Flags().Bool("etcd-upgrade", true, "Perform the upgrade of etcd.") - upgrade_applyCmd.Flags().String("feature-gates", "", "A set of key=value pairs that describe feature gates for various features.") + upgrade_applyCmd.Flags().Bool("etcd-upgrade", false, "Perform the upgrade of etcd.") upgrade_applyCmd.Flags().BoolP("force", "f", false, "Force upgrading although some requirements might not be met. This also implies non-interactive mode.") upgrade_applyCmd.Flags().StringSlice("ignore-preflight-errors", []string{}, "A list of checks whose errors will be shown as warnings. Example: 'IsPrivilegedUser,Swap'. Value 'all' ignores errors from all checks.") - upgrade_applyCmd.Flags().String("kubeconfig", "/etc/kubernetes/admin.conf", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") - upgrade_applyCmd.Flags().String("patches", "", "Path to a directory that contains files named \"target[suffix][+patchtype].extension\".") + upgrade_applyCmd.Flags().String("kubeconfig", "", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") + upgrade_applyCmd.Flags().String("patches", "", "Path to a directory that contains files named \"target[suffix][+patchtype].extension\". For example, \"kube-apiserver0+merge.yaml\" or just \"etcd.json\". \"target\" can be one of \"kube-apiserver\", \"kube-controller-manager\", \"kube-scheduler\", \"etcd\", \"kubeletconfiguration\", \"corednsdeployment\". \"patchtype\" can be one of \"strategic\", \"merge\" or \"json\" and they match the patch formats supported by kubectl. The default \"patchtype\" is \"strategic\". \"extension\" must be either \"json\" or \"yaml\". \"suffix\" is an optional string that can be used to determine which patches are applied first alpha-numerically.") upgrade_applyCmd.Flags().Bool("print-config", false, "Specifies whether the configuration file that will be used in the upgrade should be printed or not.") + upgrade_applyCmd.Flags().StringSlice("skip-phases", []string{}, "List of phases to be skipped") upgrade_applyCmd.Flags().BoolP("yes", "y", false, "Perform the upgrade and do not prompt for confirmation (non-interactive mode).") upgradeCmd.AddCommand(upgrade_applyCmd) diff --git a/completers/kubeadm_completer/cmd/upgrade_apply_phase.go b/completers/kubeadm_completer/cmd/upgrade_apply_phase.go new file mode 100644 index 00000000..9fee594b --- /dev/null +++ b/completers/kubeadm_completer/cmd/upgrade_apply_phase.go @@ -0,0 +1,18 @@ +package cmd + +import ( + "github.com/carapace-sh/carapace" + "github.com/spf13/cobra" +) + +var upgrade_apply_phaseCmd = &cobra.Command{ + Use: "phase", + Short: "Use this command to invoke single phase of the \"apply\" workflow", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(upgrade_apply_phaseCmd).Standalone() + + upgrade_applyCmd.AddCommand(upgrade_apply_phaseCmd) +} diff --git a/completers/kubeadm_completer/cmd/upgrade_apply_phase_addon.go b/completers/kubeadm_completer/cmd/upgrade_apply_phase_addon.go new file mode 100644 index 00000000..caf254de --- /dev/null +++ b/completers/kubeadm_completer/cmd/upgrade_apply_phase_addon.go @@ -0,0 +1,18 @@ +package cmd + +import ( + "github.com/carapace-sh/carapace" + "github.com/spf13/cobra" +) + +var upgrade_apply_phase_addonCmd = &cobra.Command{ + Use: "addon", + Short: "Upgrade the default kubeadm addons", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(upgrade_apply_phase_addonCmd).Standalone() + + upgrade_apply_phaseCmd.AddCommand(upgrade_apply_phase_addonCmd) +} diff --git a/completers/kubeadm_completer/cmd/upgrade_apply_phase_addon_all.go b/completers/kubeadm_completer/cmd/upgrade_apply_phase_addon_all.go new file mode 100644 index 00000000..afe928d8 --- /dev/null +++ b/completers/kubeadm_completer/cmd/upgrade_apply_phase_addon_all.go @@ -0,0 +1,28 @@ +package cmd + +import ( + "github.com/carapace-sh/carapace" + "github.com/spf13/cobra" +) + +var upgrade_apply_phase_addon_allCmd = &cobra.Command{ + Use: "all", + Short: "Upgrade all the addons", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(upgrade_apply_phase_addon_allCmd).Standalone() + + upgrade_apply_phase_addon_allCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") + upgrade_apply_phase_addon_allCmd.Flags().Bool("dry-run", false, "Do not change any state, just output what actions would be performed.") + upgrade_apply_phase_addon_allCmd.Flags().String("kubeconfig", "", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") + upgrade_apply_phase_addon_allCmd.Flags().String("patches", "", "Path to a directory that contains files named \"target[suffix][+patchtype].extension\". For example, \"kube-apiserver0+merge.yaml\" or just \"etcd.json\". \"target\" can be one of \"kube-apiserver\", \"kube-controller-manager\", \"kube-scheduler\", \"etcd\", \"kubeletconfiguration\", \"corednsdeployment\". \"patchtype\" can be one of \"strategic\", \"merge\" or \"json\" and they match the patch formats supported by kubectl. The default \"patchtype\" is \"strategic\". \"extension\" must be either \"json\" or \"yaml\". \"suffix\" is an optional string that can be used to determine which patches are applied first alpha-numerically.") + upgrade_apply_phase_addonCmd.AddCommand(upgrade_apply_phase_addon_allCmd) + + carapace.Gen(upgrade_apply_phase_addon_allCmd).FlagCompletion(carapace.ActionMap{ + "config": carapace.ActionFiles(), + "kubeconfig": carapace.ActionFiles(), + "patches": carapace.ActionFiles(), + }) +} diff --git a/completers/kubeadm_completer/cmd/upgrade_apply_phase_addon_coredns.go b/completers/kubeadm_completer/cmd/upgrade_apply_phase_addon_coredns.go new file mode 100644 index 00000000..d640f4a2 --- /dev/null +++ b/completers/kubeadm_completer/cmd/upgrade_apply_phase_addon_coredns.go @@ -0,0 +1,28 @@ +package cmd + +import ( + "github.com/carapace-sh/carapace" + "github.com/spf13/cobra" +) + +var upgrade_apply_phase_addon_corednsCmd = &cobra.Command{ + Use: "coredns", + Short: "Upgrade the CoreDNS addon", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(upgrade_apply_phase_addon_corednsCmd).Standalone() + + upgrade_apply_phase_addon_corednsCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") + upgrade_apply_phase_addon_corednsCmd.Flags().Bool("dry-run", false, "Do not change any state, just output what actions would be performed.") + upgrade_apply_phase_addon_corednsCmd.Flags().String("kubeconfig", "", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") + upgrade_apply_phase_addon_corednsCmd.Flags().String("patches", "", "Path to a directory that contains files named \"target[suffix][+patchtype].extension\". For example, \"kube-apiserver0+merge.yaml\" or just \"etcd.json\". \"target\" can be one of \"kube-apiserver\", \"kube-controller-manager\", \"kube-scheduler\", \"etcd\", \"kubeletconfiguration\", \"corednsdeployment\". \"patchtype\" can be one of \"strategic\", \"merge\" or \"json\" and they match the patch formats supported by kubectl. The default \"patchtype\" is \"strategic\". \"extension\" must be either \"json\" or \"yaml\". \"suffix\" is an optional string that can be used to determine which patches are applied first alpha-numerically.") + upgrade_apply_phase_addonCmd.AddCommand(upgrade_apply_phase_addon_corednsCmd) + + carapace.Gen(upgrade_apply_phase_addon_corednsCmd).FlagCompletion(carapace.ActionMap{ + "config": carapace.ActionFiles(), + "kubeconfig": carapace.ActionFiles(), + "patches": carapace.ActionFiles(), + }) +} diff --git a/completers/kubeadm_completer/cmd/upgrade_apply_phase_addon_kubeProxy.go b/completers/kubeadm_completer/cmd/upgrade_apply_phase_addon_kubeProxy.go new file mode 100644 index 00000000..fc07050a --- /dev/null +++ b/completers/kubeadm_completer/cmd/upgrade_apply_phase_addon_kubeProxy.go @@ -0,0 +1,26 @@ +package cmd + +import ( + "github.com/carapace-sh/carapace" + "github.com/spf13/cobra" +) + +var upgrade_apply_phase_addon_kubeProxyCmd = &cobra.Command{ + Use: "kube-proxy", + Short: "Upgrade the kube-proxy addon", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(upgrade_apply_phase_addon_kubeProxyCmd).Standalone() + + upgrade_apply_phase_addon_kubeProxyCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") + upgrade_apply_phase_addon_kubeProxyCmd.Flags().Bool("dry-run", false, "Do not change any state, just output what actions would be performed.") + upgrade_apply_phase_addon_kubeProxyCmd.Flags().String("kubeconfig", "", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") + upgrade_apply_phase_addonCmd.AddCommand(upgrade_apply_phase_addon_kubeProxyCmd) + + carapace.Gen(upgrade_apply_phase_addon_kubeProxyCmd).FlagCompletion(carapace.ActionMap{ + "config": carapace.ActionFiles(), + "kubeconfig": carapace.ActionFiles(), + }) +} diff --git a/completers/kubeadm_completer/cmd/upgrade_apply_phase_bootstrapToken.go b/completers/kubeadm_completer/cmd/upgrade_apply_phase_bootstrapToken.go new file mode 100644 index 00000000..5e689196 --- /dev/null +++ b/completers/kubeadm_completer/cmd/upgrade_apply_phase_bootstrapToken.go @@ -0,0 +1,26 @@ +package cmd + +import ( + "github.com/carapace-sh/carapace" + "github.com/spf13/cobra" +) + +var upgrade_apply_phase_bootstrapTokenCmd = &cobra.Command{ + Use: "bootstrap-token", + Short: "Configures bootstrap token and cluster-info RBAC rules", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(upgrade_apply_phase_bootstrapTokenCmd).Standalone() + + upgrade_apply_phase_bootstrapTokenCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") + upgrade_apply_phase_bootstrapTokenCmd.Flags().Bool("dry-run", false, "Do not change any state, just output what actions would be performed.") + upgrade_apply_phase_bootstrapTokenCmd.Flags().String("kubeconfig", "", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") + upgrade_apply_phaseCmd.AddCommand(upgrade_apply_phase_bootstrapTokenCmd) + + carapace.Gen(upgrade_apply_phase_bootstrapTokenCmd).FlagCompletion(carapace.ActionMap{ + "config": carapace.ActionFiles(), + "kubeconfig": carapace.ActionFiles(), + }) +} diff --git a/completers/kubeadm_completer/cmd/upgrade_apply_phase_controlPlane.go b/completers/kubeadm_completer/cmd/upgrade_apply_phase_controlPlane.go new file mode 100644 index 00000000..6229ffa9 --- /dev/null +++ b/completers/kubeadm_completer/cmd/upgrade_apply_phase_controlPlane.go @@ -0,0 +1,30 @@ +package cmd + +import ( + "github.com/carapace-sh/carapace" + "github.com/spf13/cobra" +) + +var upgrade_apply_phase_controlPlaneCmd = &cobra.Command{ + Use: "control-plane", + Short: "Upgrade the control plane", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(upgrade_apply_phase_controlPlaneCmd).Standalone() + + upgrade_apply_phase_controlPlaneCmd.Flags().Bool("certificate-renewal", false, "Perform the renewal of certificates used by component changed during upgrades.") + upgrade_apply_phase_controlPlaneCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") + upgrade_apply_phase_controlPlaneCmd.Flags().Bool("dry-run", false, "Do not change any state, just output what actions would be performed.") + upgrade_apply_phase_controlPlaneCmd.Flags().Bool("etcd-upgrade", false, "Perform the upgrade of etcd.") + upgrade_apply_phase_controlPlaneCmd.Flags().String("kubeconfig", "", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") + upgrade_apply_phase_controlPlaneCmd.Flags().String("patches", "", "Path to a directory that contains files named \"target[suffix][+patchtype].extension\". For example, \"kube-apiserver0+merge.yaml\" or just \"etcd.json\". \"target\" can be one of \"kube-apiserver\", \"kube-controller-manager\", \"kube-scheduler\", \"etcd\", \"kubeletconfiguration\", \"corednsdeployment\". \"patchtype\" can be one of \"strategic\", \"merge\" or \"json\" and they match the patch formats supported by kubectl. The default \"patchtype\" is \"strategic\". \"extension\" must be either \"json\" or \"yaml\". \"suffix\" is an optional string that can be used to determine which patches are applied first alpha-numerically.") + upgrade_apply_phaseCmd.AddCommand(upgrade_apply_phase_controlPlaneCmd) + + carapace.Gen(upgrade_apply_phase_controlPlaneCmd).FlagCompletion(carapace.ActionMap{ + "config": carapace.ActionFiles(), + "kubeconfig": carapace.ActionFiles(), + "patches": carapace.ActionFiles(), + }) +} diff --git a/completers/kubeadm_completer/cmd/upgrade_apply_phase_kubeletConfig.go b/completers/kubeadm_completer/cmd/upgrade_apply_phase_kubeletConfig.go new file mode 100644 index 00000000..88be1c6b --- /dev/null +++ b/completers/kubeadm_completer/cmd/upgrade_apply_phase_kubeletConfig.go @@ -0,0 +1,28 @@ +package cmd + +import ( + "github.com/carapace-sh/carapace" + "github.com/spf13/cobra" +) + +var upgrade_apply_phase_kubeletConfigCmd = &cobra.Command{ + Use: "kubelet-config", + Short: "Upgrade the kubelet configuration for this node", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(upgrade_apply_phase_kubeletConfigCmd).Standalone() + + upgrade_apply_phase_kubeletConfigCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") + upgrade_apply_phase_kubeletConfigCmd.Flags().Bool("dry-run", false, "Do not change any state, just output what actions would be performed.") + upgrade_apply_phase_kubeletConfigCmd.Flags().String("kubeconfig", "", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") + upgrade_apply_phase_kubeletConfigCmd.Flags().String("patches", "", "Path to a directory that contains files named \"target[suffix][+patchtype].extension\". For example, \"kube-apiserver0+merge.yaml\" or just \"etcd.json\". \"target\" can be one of \"kube-apiserver\", \"kube-controller-manager\", \"kube-scheduler\", \"etcd\", \"kubeletconfiguration\", \"corednsdeployment\". \"patchtype\" can be one of \"strategic\", \"merge\" or \"json\" and they match the patch formats supported by kubectl. The default \"patchtype\" is \"strategic\". \"extension\" must be either \"json\" or \"yaml\". \"suffix\" is an optional string that can be used to determine which patches are applied first alpha-numerically.") + upgrade_apply_phaseCmd.AddCommand(upgrade_apply_phase_kubeletConfigCmd) + + carapace.Gen(upgrade_apply_phase_kubeletConfigCmd).FlagCompletion(carapace.ActionMap{ + "config": carapace.ActionFiles(), + "kubeconfig": carapace.ActionFiles(), + "patches": carapace.ActionFiles(), + }) +} diff --git a/completers/kubeadm_completer/cmd/upgrade_apply_phase_postUpgrade.go b/completers/kubeadm_completer/cmd/upgrade_apply_phase_postUpgrade.go new file mode 100644 index 00000000..3b0542e1 --- /dev/null +++ b/completers/kubeadm_completer/cmd/upgrade_apply_phase_postUpgrade.go @@ -0,0 +1,26 @@ +package cmd + +import ( + "github.com/carapace-sh/carapace" + "github.com/spf13/cobra" +) + +var upgrade_apply_phase_postUpgradeCmd = &cobra.Command{ + Use: "post-upgrade", + Short: "Run post upgrade tasks", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(upgrade_apply_phase_postUpgradeCmd).Standalone() + + upgrade_apply_phase_postUpgradeCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") + upgrade_apply_phase_postUpgradeCmd.Flags().Bool("dry-run", false, "Do not change any state, just output what actions would be performed.") + upgrade_apply_phase_postUpgradeCmd.Flags().String("kubeconfig", "", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") + upgrade_apply_phaseCmd.AddCommand(upgrade_apply_phase_postUpgradeCmd) + + carapace.Gen(upgrade_apply_phase_postUpgradeCmd).FlagCompletion(carapace.ActionMap{ + "config": carapace.ActionFiles(), + "kubeconfig": carapace.ActionFiles(), + }) +} diff --git a/completers/kubeadm_completer/cmd/upgrade_apply_phase_preflight.go b/completers/kubeadm_completer/cmd/upgrade_apply_phase_preflight.go new file mode 100644 index 00000000..c64559ba --- /dev/null +++ b/completers/kubeadm_completer/cmd/upgrade_apply_phase_preflight.go @@ -0,0 +1,31 @@ +package cmd + +import ( + "github.com/carapace-sh/carapace" + "github.com/spf13/cobra" +) + +var upgrade_apply_phase_preflightCmd = &cobra.Command{ + Use: "preflight", + Short: "Run preflight checks before upgrade", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(upgrade_apply_phase_preflightCmd).Standalone() + + upgrade_apply_phase_preflightCmd.Flags().Bool("allow-experimental-upgrades", false, "Show unstable versions of Kubernetes as an upgrade alternative and allow upgrading to an alpha/beta/release candidate versions of Kubernetes.") + upgrade_apply_phase_preflightCmd.Flags().Bool("allow-release-candidate-upgrades", false, "Show release candidate versions of Kubernetes as an upgrade alternative and allow upgrading to a release candidate versions of Kubernetes.") + upgrade_apply_phase_preflightCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") + upgrade_apply_phase_preflightCmd.Flags().Bool("dry-run", false, "Do not change any state, just output what actions would be performed.") + upgrade_apply_phase_preflightCmd.Flags().BoolP("force", "f", false, "Force upgrading although some requirements might not be met. This also implies non-interactive mode.") + upgrade_apply_phase_preflightCmd.Flags().StringSlice("ignore-preflight-errors", []string{}, "A list of checks whose errors will be shown as warnings. Example: 'IsPrivilegedUser,Swap'. Value 'all' ignores errors from all checks.") + upgrade_apply_phase_preflightCmd.Flags().String("kubeconfig", "", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") + upgrade_apply_phase_preflightCmd.Flags().BoolP("yes", "y", false, "Perform the upgrade and do not prompt for confirmation (non-interactive mode).") + upgrade_apply_phaseCmd.AddCommand(upgrade_apply_phase_preflightCmd) + + carapace.Gen(upgrade_apply_phase_preflightCmd).FlagCompletion(carapace.ActionMap{ + "config": carapace.ActionFiles(), + "kubeconfig": carapace.ActionFiles(), + }) +} diff --git a/completers/kubeadm_completer/cmd/upgrade_apply_phase_uploadConfig.go b/completers/kubeadm_completer/cmd/upgrade_apply_phase_uploadConfig.go new file mode 100644 index 00000000..cd57e93f --- /dev/null +++ b/completers/kubeadm_completer/cmd/upgrade_apply_phase_uploadConfig.go @@ -0,0 +1,19 @@ +package cmd + +import ( + "github.com/carapace-sh/carapace" + "github.com/spf13/cobra" +) + +var upgrade_apply_phase_uploadConfigCmd = &cobra.Command{ + Use: "upload-config", + Short: "Upload the kubeadm and kubelet configurations to ConfigMaps", + Aliases: []string{"uploadconfig"}, + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(upgrade_apply_phase_uploadConfigCmd).Standalone() + + upgrade_apply_phaseCmd.AddCommand(upgrade_apply_phase_uploadConfigCmd) +} diff --git a/completers/kubeadm_completer/cmd/upgrade_apply_phase_uploadConfig_all.go b/completers/kubeadm_completer/cmd/upgrade_apply_phase_uploadConfig_all.go new file mode 100644 index 00000000..c0b8d17a --- /dev/null +++ b/completers/kubeadm_completer/cmd/upgrade_apply_phase_uploadConfig_all.go @@ -0,0 +1,26 @@ +package cmd + +import ( + "github.com/carapace-sh/carapace" + "github.com/spf13/cobra" +) + +var upgrade_apply_phase_uploadConfig_allCmd = &cobra.Command{ + Use: "all", + Short: "Upload all the configurations to ConfigMaps", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(upgrade_apply_phase_uploadConfig_allCmd).Standalone() + + upgrade_apply_phase_uploadConfig_allCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") + upgrade_apply_phase_uploadConfig_allCmd.Flags().Bool("dry-run", false, "Do not change any state, just output what actions would be performed.") + upgrade_apply_phase_uploadConfig_allCmd.Flags().String("kubeconfig", "", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") + upgrade_apply_phase_uploadConfigCmd.AddCommand(upgrade_apply_phase_uploadConfig_allCmd) + + carapace.Gen(upgrade_apply_phase_uploadConfig_allCmd).FlagCompletion(carapace.ActionMap{ + "config": carapace.ActionFiles(), + "kubeconfig": carapace.ActionFiles(), + }) +} diff --git a/completers/kubeadm_completer/cmd/upgrade_apply_phase_uploadConfig_kubeadm.go b/completers/kubeadm_completer/cmd/upgrade_apply_phase_uploadConfig_kubeadm.go new file mode 100644 index 00000000..d5785da8 --- /dev/null +++ b/completers/kubeadm_completer/cmd/upgrade_apply_phase_uploadConfig_kubeadm.go @@ -0,0 +1,26 @@ +package cmd + +import ( + "github.com/carapace-sh/carapace" + "github.com/spf13/cobra" +) + +var upgrade_apply_phase_uploadConfig_kubeadmCmd = &cobra.Command{ + Use: "kubeadm", + Short: "Upload the kubeadm ClusterConfiguration to a ConfigMap", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(upgrade_apply_phase_uploadConfig_kubeadmCmd).Standalone() + + upgrade_apply_phase_uploadConfig_kubeadmCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") + upgrade_apply_phase_uploadConfig_kubeadmCmd.Flags().Bool("dry-run", false, "Do not change any state, just output what actions would be performed.") + upgrade_apply_phase_uploadConfig_kubeadmCmd.Flags().String("kubeconfig", "", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") + upgrade_apply_phase_uploadConfigCmd.AddCommand(upgrade_apply_phase_uploadConfig_kubeadmCmd) + + carapace.Gen(upgrade_apply_phase_uploadConfig_kubeadmCmd).FlagCompletion(carapace.ActionMap{ + "config": carapace.ActionFiles(), + "kubeconfig": carapace.ActionFiles(), + }) +} diff --git a/completers/kubeadm_completer/cmd/upgrade_apply_phase_uploadConfig_kubelet.go b/completers/kubeadm_completer/cmd/upgrade_apply_phase_uploadConfig_kubelet.go new file mode 100644 index 00000000..09c72b68 --- /dev/null +++ b/completers/kubeadm_completer/cmd/upgrade_apply_phase_uploadConfig_kubelet.go @@ -0,0 +1,26 @@ +package cmd + +import ( + "github.com/carapace-sh/carapace" + "github.com/spf13/cobra" +) + +var upgrade_apply_phase_uploadConfig_kubeletCmd = &cobra.Command{ + Use: "kubelet", + Short: "Upload the kubelet configuration to a ConfigMap", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(upgrade_apply_phase_uploadConfig_kubeletCmd).Standalone() + + upgrade_apply_phase_uploadConfig_kubeletCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") + upgrade_apply_phase_uploadConfig_kubeletCmd.Flags().Bool("dry-run", false, "Do not change any state, just output what actions would be performed.") + upgrade_apply_phase_uploadConfig_kubeletCmd.Flags().String("kubeconfig", "", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") + upgrade_apply_phase_uploadConfigCmd.AddCommand(upgrade_apply_phase_uploadConfig_kubeletCmd) + + carapace.Gen(upgrade_apply_phase_uploadConfig_kubeletCmd).FlagCompletion(carapace.ActionMap{ + "config": carapace.ActionFiles(), + "kubeconfig": carapace.ActionFiles(), + }) +} diff --git a/completers/kubeadm_completer/cmd/upgrade_diff.go b/completers/kubeadm_completer/cmd/upgrade_diff.go index 3dce21c4..27c1a5e9 100644 --- a/completers/kubeadm_completer/cmd/upgrade_diff.go +++ b/completers/kubeadm_completer/cmd/upgrade_diff.go @@ -6,25 +6,21 @@ import ( ) var upgrade_diffCmd = &cobra.Command{ - Use: "diff", + Use: "diff [version]", Short: "Show what differences would be applied to existing static pod manifests. See also: kubeadm upgrade apply --dry-run", Run: func(cmd *cobra.Command, args []string) {}, } func init() { carapace.Gen(upgrade_diffCmd).Standalone() - upgrade_diffCmd.Flags().String("api-server-manifest", "/etc/kubernetes/manifests/kube-apiserver.yaml", "path to API server manifest") + upgrade_diffCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") - upgrade_diffCmd.Flags().IntP("context-lines", "c", 3, "How many lines of context in the diff") - upgrade_diffCmd.Flags().String("controller-manager-manifest", "/etc/kubernetes/manifests/kube-controller-manager.yaml", "path to controller manifest") - upgrade_diffCmd.Flags().String("kubeconfig", "/etc/kubernetes/admin.conf", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") - upgrade_diffCmd.Flags().String("scheduler-manifest", "/etc/kubernetes/manifests/kube-scheduler.yaml", "path to scheduler manifest") + upgrade_diffCmd.Flags().StringP("context-lines", "c", "", "How many lines of context in the diff") + upgrade_diffCmd.Flags().String("kubeconfig", "", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") upgradeCmd.AddCommand(upgrade_diffCmd) carapace.Gen(upgrade_diffCmd).FlagCompletion(carapace.ActionMap{ - "config": carapace.ActionFiles(), - "controller-manager-manifest": carapace.ActionFiles(), - "kubeconfig": carapace.ActionFiles(), - "scheduler-manifest": carapace.ActionFiles(), + "config": carapace.ActionFiles(), + "kubeconfig": carapace.ActionFiles(), }) } diff --git a/completers/kubeadm_completer/cmd/upgrade_node.go b/completers/kubeadm_completer/cmd/upgrade_node.go index 46f3fa8d..520e0b32 100644 --- a/completers/kubeadm_completer/cmd/upgrade_node.go +++ b/completers/kubeadm_completer/cmd/upgrade_node.go @@ -14,12 +14,14 @@ var upgrade_nodeCmd = &cobra.Command{ func init() { carapace.Gen(upgrade_nodeCmd).Standalone() - upgrade_nodeCmd.Flags().Bool("certificate-renewal", true, "Perform the renewal of certificates used by component changed during upgrades.") + + upgrade_nodeCmd.Flags().Bool("certificate-renewal", false, "Perform the renewal of certificates used by component changed during upgrades.") + upgrade_nodeCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") upgrade_nodeCmd.Flags().Bool("dry-run", false, "Do not change any state, just output the actions that would be performed.") - upgrade_nodeCmd.Flags().Bool("etcd-upgrade", true, "Perform the upgrade of etcd.") + upgrade_nodeCmd.Flags().Bool("etcd-upgrade", false, "Perform the upgrade of etcd.") upgrade_nodeCmd.Flags().StringSlice("ignore-preflight-errors", []string{}, "A list of checks whose errors will be shown as warnings. Example: 'IsPrivilegedUser,Swap'. Value 'all' ignores errors from all checks.") - upgrade_nodeCmd.Flags().String("kubeconfig", "/etc/kubernetes/kubelet.conf", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") - upgrade_nodeCmd.Flags().String("patches", "", "Path to a directory that contains files named \"target[suffix][+patchtype].extension\".") + upgrade_nodeCmd.Flags().String("kubeconfig", "", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") + upgrade_nodeCmd.Flags().String("patches", "", "Path to a directory that contains files named \"target[suffix][+patchtype].extension\". For example, \"kube-apiserver0+merge.yaml\" or just \"etcd.json\". \"target\" can be one of \"kube-apiserver\", \"kube-controller-manager\", \"kube-scheduler\", \"etcd\", \"kubeletconfiguration\", \"corednsdeployment\". \"patchtype\" can be one of \"strategic\", \"merge\" or \"json\" and they match the patch formats supported by kubectl. The default \"patchtype\" is \"strategic\". \"extension\" must be either \"json\" or \"yaml\". \"suffix\" is an optional string that can be used to determine which patches are applied first alpha-numerically.") upgrade_nodeCmd.Flags().StringSlice("skip-phases", []string{}, "List of phases to be skipped") upgradeCmd.AddCommand(upgrade_nodeCmd) diff --git a/completers/kubeadm_completer/cmd/upgrade_node_phase.go b/completers/kubeadm_completer/cmd/upgrade_node_phase.go index 0346410d..2e352d8b 100644 --- a/completers/kubeadm_completer/cmd/upgrade_node_phase.go +++ b/completers/kubeadm_completer/cmd/upgrade_node_phase.go @@ -7,11 +7,12 @@ import ( var upgrade_node_phaseCmd = &cobra.Command{ Use: "phase", - Short: "Use this command to invoke single phase of the node workflow", + Short: "Use this command to invoke single phase of the \"node\" workflow", Run: func(cmd *cobra.Command, args []string) {}, } func init() { carapace.Gen(upgrade_node_phaseCmd).Standalone() + upgrade_nodeCmd.AddCommand(upgrade_node_phaseCmd) } diff --git a/completers/kubeadm_completer/cmd/upgrade_node_phase_addon.go b/completers/kubeadm_completer/cmd/upgrade_node_phase_addon.go new file mode 100644 index 00000000..24b31c21 --- /dev/null +++ b/completers/kubeadm_completer/cmd/upgrade_node_phase_addon.go @@ -0,0 +1,18 @@ +package cmd + +import ( + "github.com/carapace-sh/carapace" + "github.com/spf13/cobra" +) + +var upgrade_node_phase_addonCmd = &cobra.Command{ + Use: "addon", + Short: "Upgrade the default kubeadm addons", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(upgrade_node_phase_addonCmd).Standalone() + + upgrade_node_phaseCmd.AddCommand(upgrade_node_phase_addonCmd) +} diff --git a/completers/kubeadm_completer/cmd/upgrade_node_phase_addon_all.go b/completers/kubeadm_completer/cmd/upgrade_node_phase_addon_all.go new file mode 100644 index 00000000..7054b6c1 --- /dev/null +++ b/completers/kubeadm_completer/cmd/upgrade_node_phase_addon_all.go @@ -0,0 +1,22 @@ +package cmd + +import ( + "github.com/carapace-sh/carapace" + "github.com/spf13/cobra" +) + +var upgrade_node_phase_addon_allCmd = &cobra.Command{ + Use: "all", + Short: "Upgrade all the addons", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(upgrade_node_phase_addon_allCmd).Standalone() + + upgrade_node_phase_addon_allCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") + upgrade_node_phase_addon_allCmd.Flags().Bool("dry-run", false, "Do not change any state, just output the actions that would be performed.") + upgrade_node_phase_addon_allCmd.Flags().String("kubeconfig", "", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") + upgrade_node_phase_addon_allCmd.Flags().String("patches", "", "Path to a directory that contains files named \"target[suffix][+patchtype].extension\". For example, \"kube-apiserver0+merge.yaml\" or just \"etcd.json\". \"target\" can be one of \"kube-apiserver\", \"kube-controller-manager\", \"kube-scheduler\", \"etcd\", \"kubeletconfiguration\", \"corednsdeployment\". \"patchtype\" can be one of \"strategic\", \"merge\" or \"json\" and they match the patch formats supported by kubectl. The default \"patchtype\" is \"strategic\". \"extension\" must be either \"json\" or \"yaml\". \"suffix\" is an optional string that can be used to determine which patches are applied first alpha-numerically.") + upgrade_node_phase_addonCmd.AddCommand(upgrade_node_phase_addon_allCmd) +} diff --git a/completers/kubeadm_completer/cmd/upgrade_node_phase_addon_coredns.go b/completers/kubeadm_completer/cmd/upgrade_node_phase_addon_coredns.go new file mode 100644 index 00000000..d5c64c74 --- /dev/null +++ b/completers/kubeadm_completer/cmd/upgrade_node_phase_addon_coredns.go @@ -0,0 +1,22 @@ +package cmd + +import ( + "github.com/carapace-sh/carapace" + "github.com/spf13/cobra" +) + +var upgrade_node_phase_addon_corednsCmd = &cobra.Command{ + Use: "coredns", + Short: "Upgrade the CoreDNS addon", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(upgrade_node_phase_addon_corednsCmd).Standalone() + + upgrade_node_phase_addon_corednsCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") + upgrade_node_phase_addon_corednsCmd.Flags().Bool("dry-run", false, "Do not change any state, just output the actions that would be performed.") + upgrade_node_phase_addon_corednsCmd.Flags().String("kubeconfig", "", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") + upgrade_node_phase_addon_corednsCmd.Flags().String("patches", "", "Path to a directory that contains files named \"target[suffix][+patchtype].extension\". For example, \"kube-apiserver0+merge.yaml\" or just \"etcd.json\". \"target\" can be one of \"kube-apiserver\", \"kube-controller-manager\", \"kube-scheduler\", \"etcd\", \"kubeletconfiguration\", \"corednsdeployment\". \"patchtype\" can be one of \"strategic\", \"merge\" or \"json\" and they match the patch formats supported by kubectl. The default \"patchtype\" is \"strategic\". \"extension\" must be either \"json\" or \"yaml\". \"suffix\" is an optional string that can be used to determine which patches are applied first alpha-numerically.") + upgrade_node_phase_addonCmd.AddCommand(upgrade_node_phase_addon_corednsCmd) +} diff --git a/completers/kubeadm_completer/cmd/upgrade_node_phase_addon_kubeProxy.go b/completers/kubeadm_completer/cmd/upgrade_node_phase_addon_kubeProxy.go new file mode 100644 index 00000000..5fd30c14 --- /dev/null +++ b/completers/kubeadm_completer/cmd/upgrade_node_phase_addon_kubeProxy.go @@ -0,0 +1,26 @@ +package cmd + +import ( + "github.com/carapace-sh/carapace" + "github.com/spf13/cobra" +) + +var upgrade_node_phase_addon_kubeProxyCmd = &cobra.Command{ + Use: "kube-proxy", + Short: "Upgrade the kube-proxy addon", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(upgrade_node_phase_addon_kubeProxyCmd).Standalone() + + upgrade_node_phase_addon_kubeProxyCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") + upgrade_node_phase_addon_kubeProxyCmd.Flags().Bool("dry-run", false, "Do not change any state, just output the actions that would be performed.") + upgrade_node_phase_addon_kubeProxyCmd.Flags().String("kubeconfig", "", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") + upgrade_node_phase_addonCmd.AddCommand(upgrade_node_phase_addon_kubeProxyCmd) + + carapace.Gen(upgrade_node_phase_addon_kubeProxyCmd).FlagCompletion(carapace.ActionMap{ + "config": carapace.ActionFiles(), + "kubeconfig": carapace.ActionFiles(), + }) +} diff --git a/completers/kubeadm_completer/cmd/upgrade_node_phase_controlPlane.go b/completers/kubeadm_completer/cmd/upgrade_node_phase_controlPlane.go index d5fc4b18..3fac2e8f 100644 --- a/completers/kubeadm_completer/cmd/upgrade_node_phase_controlPlane.go +++ b/completers/kubeadm_completer/cmd/upgrade_node_phase_controlPlane.go @@ -13,11 +13,13 @@ var upgrade_node_phase_controlPlaneCmd = &cobra.Command{ func init() { carapace.Gen(upgrade_node_phase_controlPlaneCmd).Standalone() - upgrade_node_phase_controlPlaneCmd.Flags().Bool("certificate-renewal", true, "Perform the renewal of certificates used by component changed during upgrades.") + + upgrade_node_phase_controlPlaneCmd.Flags().Bool("certificate-renewal", false, "Perform the renewal of certificates used by component changed during upgrades.") + upgrade_node_phase_controlPlaneCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") upgrade_node_phase_controlPlaneCmd.Flags().Bool("dry-run", false, "Do not change any state, just output the actions that would be performed.") - upgrade_node_phase_controlPlaneCmd.Flags().Bool("etcd-upgrade", true, "Perform the upgrade of etcd.") - upgrade_node_phase_controlPlaneCmd.Flags().String("kubeconfig", "/etc/kubernetes/kubelet.conf", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") - upgrade_node_phase_controlPlaneCmd.Flags().String("patches", "", "Path to a directory that contains files named \"target[suffix][+patchtype].extension\".") + upgrade_node_phase_controlPlaneCmd.Flags().Bool("etcd-upgrade", false, "Perform the upgrade of etcd.") + upgrade_node_phase_controlPlaneCmd.Flags().String("kubeconfig", "", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") + upgrade_node_phase_controlPlaneCmd.Flags().String("patches", "", "Path to a directory that contains files named \"target[suffix][+patchtype].extension\". For example, \"kube-apiserver0+merge.yaml\" or just \"etcd.json\". \"target\" can be one of \"kube-apiserver\", \"kube-controller-manager\", \"kube-scheduler\", \"etcd\", \"kubeletconfiguration\", \"corednsdeployment\". \"patchtype\" can be one of \"strategic\", \"merge\" or \"json\" and they match the patch formats supported by kubectl. The default \"patchtype\" is \"strategic\". \"extension\" must be either \"json\" or \"yaml\". \"suffix\" is an optional string that can be used to determine which patches are applied first alpha-numerically.") upgrade_node_phaseCmd.AddCommand(upgrade_node_phase_controlPlaneCmd) carapace.Gen(upgrade_node_phase_controlPlaneCmd).FlagCompletion(carapace.ActionMap{ diff --git a/completers/kubeadm_completer/cmd/upgrade_node_phase_kubeletConfig.go b/completers/kubeadm_completer/cmd/upgrade_node_phase_kubeletConfig.go index 6fa02a03..41fece32 100644 --- a/completers/kubeadm_completer/cmd/upgrade_node_phase_kubeletConfig.go +++ b/completers/kubeadm_completer/cmd/upgrade_node_phase_kubeletConfig.go @@ -13,8 +13,11 @@ var upgrade_node_phase_kubeletConfigCmd = &cobra.Command{ func init() { carapace.Gen(upgrade_node_phase_kubeletConfigCmd).Standalone() + + upgrade_node_phase_kubeletConfigCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") upgrade_node_phase_kubeletConfigCmd.Flags().Bool("dry-run", false, "Do not change any state, just output the actions that would be performed.") - upgrade_node_phase_kubeletConfigCmd.Flags().String("kubeconfig", "/etc/kubernetes/kubelet.conf", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") + upgrade_node_phase_kubeletConfigCmd.Flags().String("kubeconfig", "", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") + upgrade_node_phase_kubeletConfigCmd.Flags().String("patches", "", "Path to a directory that contains files named \"target[suffix][+patchtype].extension\". For example, \"kube-apiserver0+merge.yaml\" or just \"etcd.json\". \"target\" can be one of \"kube-apiserver\", \"kube-controller-manager\", \"kube-scheduler\", \"etcd\", \"kubeletconfiguration\", \"corednsdeployment\". \"patchtype\" can be one of \"strategic\", \"merge\" or \"json\" and they match the patch formats supported by kubectl. The default \"patchtype\" is \"strategic\". \"extension\" must be either \"json\" or \"yaml\". \"suffix\" is an optional string that can be used to determine which patches are applied first alpha-numerically.") upgrade_node_phaseCmd.AddCommand(upgrade_node_phase_kubeletConfigCmd) carapace.Gen(upgrade_node_phase_kubeletConfigCmd).FlagCompletion(carapace.ActionMap{ diff --git a/completers/kubeadm_completer/cmd/upgrade_node_phase_postUpgrade.go b/completers/kubeadm_completer/cmd/upgrade_node_phase_postUpgrade.go new file mode 100644 index 00000000..f6003cdb --- /dev/null +++ b/completers/kubeadm_completer/cmd/upgrade_node_phase_postUpgrade.go @@ -0,0 +1,26 @@ +package cmd + +import ( + "github.com/carapace-sh/carapace" + "github.com/spf13/cobra" +) + +var upgrade_node_phase_postUpgradeCmd = &cobra.Command{ + Use: "post-upgrade", + Short: "Run post upgrade tasks", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(upgrade_node_phase_postUpgradeCmd).Standalone() + + upgrade_node_phase_postUpgradeCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") + upgrade_node_phase_postUpgradeCmd.Flags().Bool("dry-run", false, "Do not change any state, just output the actions that would be performed.") + upgrade_node_phase_postUpgradeCmd.Flags().String("kubeconfig", "", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") + upgrade_node_phaseCmd.AddCommand(upgrade_node_phase_postUpgradeCmd) + + carapace.Gen(upgrade_node_phase_postUpgradeCmd).FlagCompletion(carapace.ActionMap{ + "config": carapace.ActionFiles(), + "kubeconfig": carapace.ActionFiles(), + }) +} diff --git a/completers/kubeadm_completer/cmd/upgrade_node_phase_preflight.go b/completers/kubeadm_completer/cmd/upgrade_node_phase_preflight.go index 4fa2027e..74405f05 100644 --- a/completers/kubeadm_completer/cmd/upgrade_node_phase_preflight.go +++ b/completers/kubeadm_completer/cmd/upgrade_node_phase_preflight.go @@ -14,6 +14,8 @@ var upgrade_node_phase_preflightCmd = &cobra.Command{ func init() { carapace.Gen(upgrade_node_phase_preflightCmd).Standalone() + + upgrade_node_phase_preflightCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") upgrade_node_phase_preflightCmd.Flags().StringSlice("ignore-preflight-errors", []string{}, "A list of checks whose errors will be shown as warnings. Example: 'IsPrivilegedUser,Swap'. Value 'all' ignores errors from all checks.") upgrade_node_phaseCmd.AddCommand(upgrade_node_phase_preflightCmd) diff --git a/completers/kubeadm_completer/cmd/upgrade_plan.go b/completers/kubeadm_completer/cmd/upgrade_plan.go index 258a0c6b..e8ece1bb 100644 --- a/completers/kubeadm_completer/cmd/upgrade_plan.go +++ b/completers/kubeadm_completer/cmd/upgrade_plan.go @@ -3,29 +3,35 @@ package cmd import ( "github.com/carapace-sh/carapace" "github.com/carapace-sh/carapace-bin/completers/kubeadm_completer/cmd/action" + "github.com/carapace-sh/carapace-bin/pkg/actions/tools/kubeadm" "github.com/spf13/cobra" ) var upgrade_planCmd = &cobra.Command{ - Use: "plan", - Short: "Check which versions are available to upgrade to and validate whether your current cluster is upgradeable. To skip the internet check, pass in the optional [version] parameter", + Use: "plan [version] [flags]", + Short: "Check which versions are available to upgrade to and validate whether your current cluster is upgradeable.", Run: func(cmd *cobra.Command, args []string) {}, } func init() { carapace.Gen(upgrade_planCmd).Standalone() + upgrade_planCmd.Flags().Bool("allow-experimental-upgrades", false, "Show unstable versions of Kubernetes as an upgrade alternative and allow upgrading to an alpha/beta/release candidate versions of Kubernetes.") + upgrade_planCmd.Flags().Bool("allow-missing-template-keys", false, "If true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats.") upgrade_planCmd.Flags().Bool("allow-release-candidate-upgrades", false, "Show release candidate versions of Kubernetes as an upgrade alternative and allow upgrading to a release candidate versions of Kubernetes.") upgrade_planCmd.Flags().String("config", "", "Path to a kubeadm configuration file.") - upgrade_planCmd.Flags().String("feature-gates", "", "A set of key=value pairs that describe feature gates for various features.") + upgrade_planCmd.Flags().Bool("etcd-upgrade", false, "Perform the upgrade of etcd.") upgrade_planCmd.Flags().StringSlice("ignore-preflight-errors", []string{}, "A list of checks whose errors will be shown as warnings. Example: 'IsPrivilegedUser,Swap'. Value 'all' ignores errors from all checks.") - upgrade_planCmd.Flags().String("kubeconfig", "/etc/kubernetes/admin.conf", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") + upgrade_planCmd.Flags().String("kubeconfig", "", "The kubeconfig file to use when talking to the cluster. If the flag is not set, a set of standard locations can be searched for an existing kubeconfig file.") + upgrade_planCmd.Flags().StringP("output", "o", "", "Output format. One of: text|json|yaml|go-template|go-template-file|template|templatefile|jsonpath|jsonpath-as-json|jsonpath-file.") upgrade_planCmd.Flags().Bool("print-config", false, "Specifies whether the configuration file that will be used in the upgrade should be printed or not.") + upgrade_planCmd.Flags().Bool("show-managed-fields", false, "If true, keep the managedFields when printing objects in JSON or YAML format.") upgradeCmd.AddCommand(upgrade_planCmd) carapace.Gen(upgrade_planCmd).FlagCompletion(carapace.ActionMap{ "config": carapace.ActionFiles(), "ignore-preflight-errors": action.ActionChecks().UniqueList(","), "kubeconfig": carapace.ActionFiles(), + "output": kubeadm.ActionOutputFormats(), }) } diff --git a/completers/kubeadm_completer/cmd/version.go b/completers/kubeadm_completer/cmd/version.go index 3a834604..5070c8a8 100644 --- a/completers/kubeadm_completer/cmd/version.go +++ b/completers/kubeadm_completer/cmd/version.go @@ -13,6 +13,7 @@ var versionCmd = &cobra.Command{ func init() { carapace.Gen(versionCmd).Standalone() + versionCmd.Flags().StringP("output", "o", "", "Output format; available options are 'yaml', 'json' and 'short'") rootCmd.AddCommand(versionCmd) diff --git a/pkg/actions/tools/kubeadm/feature.go b/pkg/actions/tools/kubeadm/feature.go new file mode 100644 index 00000000..4d56d3bd --- /dev/null +++ b/pkg/actions/tools/kubeadm/feature.go @@ -0,0 +1,27 @@ +package kubeadm + +import ( + "github.com/carapace-sh/carapace" + "github.com/carapace-sh/carapace/pkg/style" +) + +// ActionFeatureGates completes feature gates +// +// ControlPlaneKubeletLocalMode=true +// NodeLocalCRISocket=false +func ActionFeatureGates() carapace.Action { + return carapace.ActionMultiPartsN("=", 2, func(c carapace.Context) carapace.Action { + switch len(c.Parts) { + case 0: + return carapace.ActionValues( + "ControlPlaneKubeletLocalMode", + "NodeLocalCRISocket", + "PublicKeysECDSA", + "RootlessControlPlane", + "WaitForAllControlPlaneComponents", + ).Suffix("=") + default: + return carapace.ActionValues("true", "false").StyleF(style.ForKeyword) + } + }).List(",") +} diff --git a/pkg/actions/tools/kubeadm/output.go b/pkg/actions/tools/kubeadm/output.go new file mode 100644 index 00000000..9f75e262 --- /dev/null +++ b/pkg/actions/tools/kubeadm/output.go @@ -0,0 +1,22 @@ +package kubeadm + +import "github.com/carapace-sh/carapace" + +// ActionOutputFormats completes output formats +// +// go-template +// json +func ActionOutputFormats() carapace.Action { + return carapace.ActionValues( + "go-template", + "go-template-file", + "json", + "jsonpath", + "jsonpath-as-json", + "jsonpath-file", + "template", + "templatefile", + "text", + "yaml", + ).Tag("output formats") +}