Add kustomizations removal to uninstall cmd
This commit is contained in:
@@ -3,6 +3,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/manifoldco/promptui"
|
"github.com/manifoldco/promptui"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
@@ -25,11 +26,14 @@ cluster role bindings and CRDs.`,
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
uninstallCRDs bool
|
uninstallCRDs bool
|
||||||
|
uninstallKustomizations bool
|
||||||
uninstallDryRun bool
|
uninstallDryRun bool
|
||||||
uninstallSilent bool
|
uninstallSilent bool
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
uninstallCmd.Flags().BoolVarP(&uninstallKustomizations, "kustomizations", "", false,
|
||||||
|
"removes all kustomizations previously installed")
|
||||||
uninstallCmd.Flags().BoolVarP(&uninstallCRDs, "crds", "", false,
|
uninstallCmd.Flags().BoolVarP(&uninstallCRDs, "crds", "", false,
|
||||||
"removes all CRDs previously installed")
|
"removes all CRDs previously installed")
|
||||||
uninstallCmd.Flags().BoolVarP(&uninstallDryRun, "dry-run", "", false,
|
uninstallCmd.Flags().BoolVarP(&uninstallDryRun, "dry-run", "", false,
|
||||||
@@ -57,6 +61,20 @@ func uninstallCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if uninstallKustomizations {
|
||||||
|
logAction("uninstalling kustomizations")
|
||||||
|
command := fmt.Sprintf("kubectl -n %s delete kustomizations --all --timeout=%s %s",
|
||||||
|
namespace, timeout.String(), dryRun)
|
||||||
|
if _, err := utils.execCommand(ctx, ModeOS, command); err != nil {
|
||||||
|
return fmt.Errorf("uninstall failed")
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: use the kustomizations snapshots to create a list of objects
|
||||||
|
// that are subject to deletion and wait for all of them to be terminated
|
||||||
|
logWaiting("waiting on GC")
|
||||||
|
time.Sleep(30 * time.Second)
|
||||||
|
}
|
||||||
|
|
||||||
kinds := "namespace,clusterroles,clusterrolebindings"
|
kinds := "namespace,clusterroles,clusterrolebindings"
|
||||||
if uninstallCRDs {
|
if uninstallCRDs {
|
||||||
kinds += ",crds"
|
kinds += ",crds"
|
||||||
|
|||||||
Reference in New Issue
Block a user