Skip to content

Commit

Permalink
Enabled operator installation for karmor
Browse files Browse the repository at this point in the history
Signed-off-by: rootxrishabh <[email protected]>
  • Loading branch information
rootxrishabh committed Feb 13, 2024
1 parent d0327f5 commit 5b01f5c
Show file tree
Hide file tree
Showing 5 changed files with 1,158 additions and 606 deletions.
16 changes: 9 additions & 7 deletions cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@ var installCmd = &cobra.Command{
Short: "Install KubeArmor in a Kubernetes Cluster",
Long: `Install KubeArmor in a Kubernetes Clusters`,
RunE: func(cmd *cobra.Command, args []string) error {
if err := installOptions.Env.CheckAndSetValidEnvironmentOption(cmd.Flag("env").Value.String()); err != nil {
return fmt.Errorf("error in checking environment option: %v", err)
}
if err := install.K8sInstaller(client, installOptions); err != nil {
return err
if installOptions.Legacy {
if err := install.K8sLegacyInstaller(client, installOptions); err != nil {
return fmt.Errorf("error installing kubearmor in legacy mode: %v", err)
}
} else {
if err := install.K8sInstaller(client, installOptions); err != nil {
return fmt.Errorf("error installing kubearmor: %v", err)
}
}
return nil
},
Expand All @@ -43,7 +46,6 @@ func init() {
installCmd.Flags().BoolVar(&installOptions.Save, "save", false, "Save KubeArmor Manifest ")
installCmd.Flags().BoolVar(&installOptions.Verify, "verify", true, "Verify whether all KubeArmor resources are created, running and also probes whether KubeArmor has armored the cluster or not")
installCmd.Flags().BoolVar(&installOptions.Local, "local", false, "Use Local KubeArmor Images (sets ImagePullPolicy to 'IfNotPresent') ")
installCmd.Flags().StringVarP(&installOptions.Env.Environment, "env", "e", "", "Supported KubeArmor Environment [k0s,k3s,microK8s,minikube,gke,bottlerocket,eks,docker,oke,generic]")
installCmd.Flags().StringVarP(&installOptions.ImageRegistry, "registry", "r", "", "Image registry to use to pull the images")

installCmd.Flags().BoolVar(&installOptions.Legacy, "legacy", false, "Installs kubearmor in legacy mode if set to true")
}
9 changes: 7 additions & 2 deletions cmd/uninstall.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@ var uninstallCmd = &cobra.Command{
Short: "Uninstall KubeArmor from a Kubernetes Cluster",
Long: `Uninstall KubeArmor from a Kubernetes Clusters`,
RunE: func(cmd *cobra.Command, args []string) error {

Check warning on line 18 in cmd/uninstall.go

View workflow job for this annotation

GitHub Actions / go-lint

parameter 'args' seems to be unused, consider removing or renaming it as _

Check warning on line 18 in cmd/uninstall.go

View workflow job for this annotation

GitHub Actions / go-lint

parameter 'cmd' seems to be unused, consider removing or renaming it as _
err := install.K8sUninstaller(client, uninstallOptions)
return err
if err := install.K8sUninstaller(client, uninstallOptions); err != nil {
if err := install.K8sLegacyUninstaller(client, uninstallOptions); err != nil {
return err
}
}
return nil
},
}

Expand All @@ -27,4 +31,5 @@ func init() {
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.Legacy, "legacy", false, "Legacy uninstallation for kubearmor")
}
Loading

0 comments on commit 5b01f5c

Please sign in to comment.