While I haven't seen any successful attempts to run eBPF natively on macOS, it's still possible through Lima.
Lima lets you spin up Linux virtual machines on macOS, making it a convenient option for running eBPF programs.
Yes, there's a virtualization overhead since it relies on QEMU under the hood, but in many cases, you just need a test environment rather than a fully-fledged production setup.
Over the past week, I had the privilege of speaking with developers at various meetups about eBPF.
While they were excited about running programs in the Linux kernel, many felt limited because they were macOS users.
But that really shouldn’t be the problem. Let me show you why.
To avoid confusion, Lima wasn’t specifically designed for eBPF, but it’s a generic tool that allows you to spin VM environments based on some pre-defined configuration.
In my GitHub Repository, you can find a default.yaml
configuration file for an eBPF-ready Lima environment.
In short, it installs most of the eBPF dependencies so you can solely focus on writing eBPF code — be it in ebpf-go, Python using BCC framework or even bpftrace.
To get you up and running quickly:
Install Lima and QEMU.
Launch the VM with the pre-configured setup I’ve prepared for you:
It takes a little time to start up, so grab a coffee while you wait.
Once it's ready, you're all set to try out an eBPF program.
Feel free to clone my ebpf-stack GitHub repository, which includes various 'Hello World' examples in different programming languages.
You'll find instructions on running eBPF programs in the corresponding directories inside the repository.
And that's it—short and sweet this time!
⏪ Did you miss the previous issues? I'm sure you wouldn't, but JUST in case:
I hope you find this resource helpful. Keep an eye out for more updates and developments in eBPF in next week's newsletter.
Until then, keep 🐝-ing!
Warm regards, Teodor