Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for all kubearmor command line configurations using KubeArmorConfig CR #1501

Open
rksharma95 opened this issue Nov 9, 2023 · 10 comments
Assignees
Labels
enhancement New feature or request

Comments

@rksharma95
Copy link
Collaborator

Feature Request

Short Description

Add Support to the KubeArmorConfig to pass all the command line configurations supported by the kubearmor. KubeArmorConfig already support some of the configurations i.e. defaultPosture, defaultVisibility etc. that can be in-effect dynamically. the remaining configurations are mainly pre-install configurations and will require KubeArmor to reboot. Operator is reconciling to watch kubearmor daemonset and can handle any configuration updates.

Is your feature request related to a problem? Please describe the use case.

it will enable the user to provide kubearmor configurations using KubeArmorConfig CR.

Describe the solution you'd like

apiVersion: operator.kubearmor.com/v1
kind: KubeArmorConfig
Spec:
  cluster: "cluster-name"
  host: "host-name"
  grpc: "grpc-port"
  ...

Describe alternatives you've considered

  • feel free to discuss/propose spec design to support the kubearmor configurations.
@rksharma95 rksharma95 added the enhancement New feature or request label Nov 9, 2023
@rootxrishabh
Copy link
Member

rootxrishabh commented Jan 7, 2024

Hey @rksharma95, KubeArmorConfig already handles defaultPosture and defaultVisibility as shown here. The goal is to implement the remaing configurations from kubearmor cli to kubearmor config. Is my interpretation correct?
Kubearmor CLI options (some to be implemented)-

  -bpfFsPath string
        Path to the BPF filesystem to use for storing maps (default "/sys/fs/bpf")
  -cluster string
        cluster name (default "default")
  -coverageTest
        enabling CoverageTest
  -criSocket string
        path to CRI socket (format: unix:///path/to/file.sock)
  -debug
        Enable/Disable pushing KubeArmor debug logs over gRPC. NOTE: Set environment DEBUG=true to configure stdout debug logging
  -defaultCapabilitiesPosture string
        configuring default enforcement action in global capability context {allow|audit|block} (default "audit")
  -defaultFilePosture string
        configuring default enforcement action in global file context {allow|audit|block} (default "audit")
  -defaultNetworkPosture string
        configuring default enforcement action in global network context {allow|audit|block} (default "audit")
  -defaultPostureLogs
        Default Posture Alerts (for Apparmor only) (default true)
  -enableKubeArmorHostPolicy
        enabling KubeArmorHostPolicy
  -enableKubeArmorPolicy
        enabling KubeArmorPolicy (default true)
  -enableKubeArmorVm
        enabling KubeArmorVM
  -enforcerAlerts
        ebpf alerts (default true)
  -gRPC string
        gRPC port number (default "32767")
  -host string
        host name (default "ubuntu-jammy-1")
  -hostDefaultCapabilitiesPosture string
        configuring default enforcement action in global capability context {allow|audit|block} (default "audit")
  -hostDefaultFilePosture string
        configuring default enforcement action in global file context {allow|audit|block} (default "audit")
  -hostDefaultNetworkPosture string
        configuring default enforcement action in global network context {allow|audit|block} (default "audit")
  -hostVisibility string
        Host Visibility to use [process,file,network,capabilities,none] (default "none" for k8s, "process,file,network,capabilities" for VM) (default "default")
  -k8s
        is k8s env? (default true)
  -kubeconfig string
        Paths to a kubeconfig. Only required if out-of-cluster.
  -logPath string
        log file path, {path|stdout|none} (default "none")
  -lsm string
        lsm preference order to use, available lsms [bpf, apparmor, selinux] (default "bpf,apparmor,selinux")
  -seLinuxProfileDir string
        SELinux profile directory (default "/tmp/kubearmor.selinux")
  -untrackedNs string
        Namespaces which are not being tracked, default untracked:[kube-system, kubearmor] (default "kube-system,kubearmor")
  -visibility string
        Container Visibility to use [process,file,network,capabilities,none] (default "process,file,network,capabilities")

@rootxrishabh
Copy link
Member

Can you explain 'Operator is reconciling to watch kubearmor daemonset' a bit in detail? Is it that the operator using the watch API of Kubernetes and it will implement any changes that require restart automatically and the user won't have to manually reboot kubearmor?

@rksharma95
Copy link
Collaborator Author

for example, we are using the image provided by the user using the CR KubeArmorConfig here, similarly we can define other configuration options and can use them to define the daemonset initially.

daemonset.Spec.Template.Spec.Containers[0].Image = common.GetApplicationImage(common.KubeArmorName)

and to update the daemonset for each update event on KubeArmorConfig we can make use of the watcher defined here:
func (clusterWatcher *ClusterWatcher) WatchConfigCrd() {

let me know if you have any questions.

@rootxrishabh
Copy link
Member

To my understanding, the daemonset configuration has to be extended to handle these CLI configurations at install time. Also, the operator CRD will have to be extended to make these options available. Once at least these steps are done(there could be more) the watcher will automatically take care of updates on the CR. Is my interpretation correct?

@rksharma95
Copy link
Collaborator Author

daemonset accepts these configurations as command-line arguments, however it would be better if we can handle these configurations with existing configmap kubearmor-config.

type KubearmorConfig struct {

yes you're right these configurations need to be part of KubeArmorConfig CR spec and need to be handled as part of this issue.
the watcher will required related changes to handle the change in these configs at runtime.

@rootxrishabh
Copy link
Member

Working on a PR : )

@rootxrishabh rootxrishabh self-assigned this Jan 10, 2024
@rootxrishabh
Copy link
Member

@rksharma95 Sorry for an array of doubts 😅. I understand that we are getting the config map from kubearmor-confg but how does a user-supplied value(such as image or init-image) in the CR is used to configure the deployments in the operator? I am unable to find that code piece.
Thank You

@rksharma95
Copy link
Collaborator Author

reconciler/watcher WatchRequiredResource() watches all the resources except daemonset and same can be used to initialize resources i.e.

for dynamic updates, let's take a look here how we're updating the images

func (clusterWatcher *ClusterWatcher) UpdateKubeArmorImages(images []string) error {

let me know if you have any questions.

@DelusionalOptimist
Copy link
Member

Folks how about instead of adding all fields to the CR we just add a cli_arguments field? Most of this is advanced configuration anyways and I'm not sure if most of the users will be needing it. It'll just make our CR more verbose.
Just a thought. Need more opinions. cc @rksharma95 @rootxrishabh

@rootxrishabh
Copy link
Member

@DelusionalOptimist Agreed. Advanced configurations can be bundled into an array field. Haven't had the time to get on this, will start again soon!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants