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]>

Logs improved, flags implemented for --save

Signed-off-by: rootxrishabh <[email protected]>

Added operator configuration

Signed-off-by: rootxrishabh <[email protected]>

Improvements made

Signed-off-by: rootxrishabh <[email protected]>
  • Loading branch information
rootxrishabh committed Mar 6, 2024
1 parent 00ceb3e commit dcf6e79
Show file tree
Hide file tree
Showing 5 changed files with 1,236 additions and 612 deletions.
19 changes: 13 additions & 6 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 @@ -34,19 +37,23 @@ func init() {
installCmd.Flags().StringVarP(&installOptions.Namespace, "namespace", "n", "kubearmor", "Namespace for resources")
installCmd.Flags().StringVarP(&installOptions.KubearmorImage, "image", "i", "kubearmor/kubearmor:stable", "Kubearmor daemonset image to use")
installCmd.Flags().StringVarP(&installOptions.InitImage, "init-image", "", "kubearmor/kubearmor-init:stable", "Kubearmor daemonset init container image to use")
installCmd.Flags().StringVarP(&installOptions.OperatorImage, "operator-image", "", "kubearmor/kubearmor-operator:latest", "Kubearmor operator container image to use")
installCmd.Flags().StringVarP(&installOptions.ControllerImage, "controller-image", "", "kubearmor/kubearmor-controller:latest", "Kubearmor controller image to use")
installCmd.Flags().StringVarP(&installOptions.RelayImage, "relay-image", "", "kubearmor/kubearmor-relay-server:latest", "Kubearmor relay image to use")
installCmd.Flags().StringVarP(&installOptions.KubeArmorTag, "tag", "t", "", "Change image tag/version for default kubearmor images (This will overwrite the tags provided in --image/--init-image)")
installCmd.Flags().StringVarP(&installOptions.KubeArmorRelayTag, "relay-tag", "", "", "Change image tag/version for default kubearmor-relay image (This will overwrite the tag provided in --relay-image)")
installCmd.Flags().StringVarP(&installOptions.KubeArmorControllerTag, "controller-tag", "", "", "Change image tag/version for default kubearmor-controller image (This will overwrite the tag provided in --controller-image)")
installCmd.Flags().StringVarP(&installOptions.KubeArmorOperatorTag, "operator-tag", "", "", "Change image tag/version for default kubearmor-operator image (This will overwrite the tag provided in --operator-image)")
installCmd.Flags().StringVarP(&installOptions.Audit, "audit", "a", "", "Kubearmor Audit Posture Context [all,file,network,capabilities]")
installCmd.Flags().StringVarP(&installOptions.Block, "block", "b", "", "Kubearmor Block Posture Context [all,file,network,capabilities]")
installCmd.Flags().StringVarP(&installOptions.Visibility, "viz", "", "", "Kubearmor Telemetry Visibility [process,file,network,none]")
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")
installCmd.Flags().BoolVar(&installOptions.SkipDeploy, "skip-deploy", false, "Saves kubearmor operator CR manifest rather than deploying it")
installCmd.Flags().BoolVar(&installOptions.PreserveUpstream, "preserve-upstream", true, "Do not override the image registry when using -r flag, prefix only")

installCmd.MarkFlagsMutuallyExclusive("verify", "save")
}
8 changes: 6 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 {
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 Down
Loading

0 comments on commit dcf6e79

Please sign in to comment.