From 7179ca39885488575fbf22e05fe575d38ef86d3b Mon Sep 17 00:00:00 2001 From: Andrey Smirnov Date: Thu, 11 Mar 2021 23:40:11 +0300 Subject: [PATCH] fix: update output of `convert-k8s` command This includes Sean's comments from #3278 and introduces a new flag which is referenced in manual conversion process document. Signed-off-by: Andrey Smirnov (cherry picked from commit 6f7df3da1e147212e6d4b40a5de65e5ca8be84db) --- cmd/talosctl/cmd/talos/convert-k8s.go | 5 +++++ pkg/cluster/kubernetes/convert.go | 13 ++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/cmd/talosctl/cmd/talos/convert-k8s.go b/cmd/talosctl/cmd/talos/convert-k8s.go index 08c1eb4dff..8c5affc4bf 100644 --- a/cmd/talosctl/cmd/talos/convert-k8s.go +++ b/cmd/talosctl/cmd/talos/convert-k8s.go @@ -33,6 +33,11 @@ var convertOptions k8s.ConvertOptions func init() { convertK8sCmd.Flags().StringVar(&convertOptions.ControlPlaneEndpoint, "endpoint", "", "the cluster control plane endpoint") convertK8sCmd.Flags().BoolVar(&convertOptions.ForceYes, "force", false, "skip prompts, assume yes") + convertK8sCmd.Flags().BoolVar(&convertOptions.OnlyRemoveInitializedKey, "remove-initialized-key", false, "only remove bootkube initialized key (used in manual conversion)") + + // hiding this flag as it should only be used in manual process (and it's documented there), but should never be used in automatic conversion + convertK8sCmd.Flags().MarkHidden("remove-initialized-key") //nolint: errcheck + addCommand(convertK8sCmd) } diff --git a/pkg/cluster/kubernetes/convert.go b/pkg/cluster/kubernetes/convert.go index 65991b3d11..fbd011e9d3 100644 --- a/pkg/cluster/kubernetes/convert.go +++ b/pkg/cluster/kubernetes/convert.go @@ -41,8 +41,9 @@ import ( // ConvertOptions are options for convert tasks. type ConvertOptions struct { - ControlPlaneEndpoint string - ForceYes bool + ControlPlaneEndpoint string + ForceYes bool + OnlyRemoveInitializedKey bool masterNodes []string } @@ -73,6 +74,11 @@ func ConvertToStaticPods(ctx context.Context, cluster ConvertProvider, options C return fmt.Errorf("no master nodes discovered") } + // only used in manual conversion process + if options.OnlyRemoveInitializedKey { + return removeInitializedKey(ctx, cluster, options.masterNodes[0]) + } + fmt.Printf("discovered master nodes %q\n", options.masterNodes) selfHosted, err := IsSelfHostedControlPlane(ctx, cluster, options.masterNodes[0]) @@ -95,7 +101,8 @@ func ConvertToStaticPods(ctx context.Context, cluster ConvertProvider, options C fmt.Printf("\ttalosctl -n get %s\n", k8s.StaticPodType) fmt.Printf("\ttalosctl -n get %s\n", k8s.ManifestType) fmt.Println() - fmt.Println("bootstrap manifests will only be applied for missing resources, existing resources will not be updated") + fmt.Println("in order to remove self-hosted control plane, pod-checkpointer component needs to be disabled") + fmt.Println("once pod-checkpointer is disabled, the cluster shouldn't be rebooted until the entire conversion process is complete") if !options.ForceYes { var yes bool