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

migrate bcc based system monitor to libbpf and cilium/ebpf #677

Merged
merged 10 commits into from
Jul 20, 2022

Conversation

daemon1024
Copy link
Member

@daemon1024 daemon1024 commented Apr 21, 2022

Why?

  • BCC compiles programs at runtime, which has heavy CPU and memory resource usage.
  • eliminate libbcc dependency on the host machine
  • smaller main image size, since compilation is decoupled from the main container.
  • Making KubeArmor binary portable provided no CGO dependency

Follow Up #399

Fixes #38

TODO

  • Test systemd on centos/rhel
  • Handle GKE Headers
  • Update Docs

@codecov-commenter
Copy link

codecov-commenter commented Apr 21, 2022

Codecov Report

Merging #677 (1fcb2ad) into main (81369e1) will increase coverage by 0.21%.
The diff coverage is 64.28%.

@@            Coverage Diff             @@
##             main     #677      +/-   ##
==========================================
+ Coverage   40.08%   40.29%   +0.21%     
==========================================
  Files          29       29              
  Lines        9348     9318      -30     
==========================================
+ Hits         3747     3755       +8     
+ Misses       5110     5075      -35     
+ Partials      491      488       -3     
Impacted Files Coverage Δ
KubeArmor/monitor/systemMonitor.go 58.28% <64.28%> (+7.11%) ⬆️
KubeArmor/monitor/syscallParser.go 63.98% <0.00%> (-0.84%) ⬇️
KubeArmor/feeder/policyMatcher.go 49.16% <0.00%> (+0.41%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 81369e1...1fcb2ad. Read the comment docs.

@daemon1024 daemon1024 force-pushed the bcc-to-libbpf branch 10 times, most recently from 6fd4425 to 05175f1 Compare April 22, 2022 03:56
@daemon1024 daemon1024 force-pushed the bcc-to-libbpf branch 18 times, most recently from 25f28d1 to aba14d8 Compare May 3, 2022 18:09
@daemon1024 daemon1024 force-pushed the bcc-to-libbpf branch 2 times, most recently from c32b78d to 2354b42 Compare July 15, 2022 14:04
@daemon1024
Copy link
Member Author

daemon1024 commented Jul 18, 2022

Tested on

  • GKE Regular Channel
  • GKE Rapid Release Channel
  • BottleRocket EKS

@daemon1024
Copy link
Member Author

Fixed compilation on BottleRocket EKS, The object files were shipping with the docker container causing non native bpf code to run resulting in no telemetry data.

updated docker container to compile ebpf code at runtime

Signed-off-by: daemon1024 <[email protected]>
- Use init container for compiling BPF code

Signed-off-by: daemon1024 <[email protected]>
- setup CI to test systemd
- add llvm toolchain dep instead of bcc
- eliminate stdarg dep from clang/gcc std include

Signed-off-by: daemon1024 <[email protected]>
@daemon1024 daemon1024 requested review from nyrahul and nam-jaehyun and removed request for nam-jaehyun July 19, 2022 07:38
Copy link
Contributor

@nyrahul nyrahul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍🏼 👍🏼

…t container

- Using lib modules for kernel header detection which symlinks to appropriate directory in usr src
- clean up object files and added object files to docker ignore

Signed-off-by: daemon1024 <[email protected]>
@DelusionalOptimist
Copy link
Member

Lots of tests now hehe 😛

Copy link
Member

@DelusionalOptimist DelusionalOptimist left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

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

Successfully merging this pull request may close these issues.

ContainerMonitor: use libbpf instead of bcc
5 participants