kubearmor-client/cmd/uninstall.go
itsCheithanya e448ed775a
Support karmor install for non-k8s environment (#475)
* feat: karmor install in unorchestrated env and vm

Signed-off-by: Aryan-sharma11 <aryan1126.sharma@gmail.com>

* upgrade dependecies

Signed-off-by: Aryan-sharma11 <aryan1126.sharma@gmail.com>

---------

Signed-off-by: Aryan-sharma11 <aryan1126.sharma@gmail.com>
Co-authored-by: Aryan-sharma11 <aryan1126.sharma@gmail.com>
2025-05-20 12:28:28 +05:30

41 lines
1.4 KiB
Go

// SPDX-License-Identifier: Apache-2.0
// Copyright 2021 Authors of KubeArmor
package cmd
import (
"github.com/kubearmor/kubearmor-client/install"
"github.com/spf13/cobra"
)
var uninstallOptions install.Options
// uninstallCmd represents the get command
var uninstallCmd = &cobra.Command{
Use: "uninstall",
Short: "Uninstall KubeArmor",
Long: `Uninstall KubeArmor in either Kubernetes or non-Kubernetes mode.`,
RunE: func(cmd *cobra.Command, args []string) error {
//check for systemd or docker installation
exist := install.CheckAndRemoveKAVmInstallation()
if !exist {
if err := install.K8sUninstaller(client, uninstallOptions); err != nil {
if err := install.K8sLegacyUninstaller(client, uninstallOptions); err != nil {
return err
}
}
return nil
}
return nil
},
}
func init() {
rootCmd.AddCommand(uninstallCmd)
uninstallCmd.Flags().StringVarP(&uninstallOptions.Namespace, "namespace", "n", "", "If no namespace is specified, it defaults to all namespaces and deletes all KubeArmor objects across them.")
uninstallCmd.Flags().BoolVar(&uninstallOptions.Force, "force", false, "Force remove KubeArmor annotations from deployments. (Deployments might be restarted)")
uninstallCmd.Flags().BoolVar(&uninstallOptions.Verify, "verify", true, "Verify whether all KubeArmor resources are cleaned up or not")
uninstallCmd.Flags().BoolVar(&uninstallOptions.NonK8s, "nonk8s", false, "uninstall docker or systemd KubeArmor")
}