Falco on WSL2 with a custom kernel
Falco on WSL2
You love Falco, just read the awesome blog Falco in 2020 - The Falco Project, and want to be part of this growing and wonderful community. "But" you are on Windows 10 and wonder how to run it?
Well, the wait is over! Follow the Corsair on his WSL2 boat.
Prerequisites
In this blog post, the following technologies will be used:
Windows 10 Insiders (Dev channel)
- The version 21277 is the one used
WSL2 feature enabled and default distribution installed
In this version, this has been done with the command:
However, in this blog post, the [Ubuntu Community Preview](Announcing Ubuntu on Windows Community Preview - WSL2 - Ubuntu Community Hub) distro will be the one used
Linux kernel version 5.10.4 (latest stable)
The default WSL2 kernel is now: 5.4.72-microsoft-standard-WSL2
If you still have a WSL2 kernel 4.x, then you can update it with the command
Attention: by compiling a new WSL2 kernel, the Microsoft custom module "DXGKRNL" will not be available
[Optional]: Windows Terminal
A (custom) Kernel for WSL2
First thing first, I won't be explain in details how to compile a kernel for WSL2. Simply because I already did that for the ZFS module.
This also means, I will have the pleasure to provide you with the juicy bits directly.
Note: to ensure the best performances, all the work of compilation will be done from within the WSL2 filesystem.
Let's launch the terminal with the WSL2 distro:
With all these steps done, WSL2 can now be "rebooted" by running the following command in Powershell:
Launch again a terminal with your WSL2 distro and confirm the new kernel is now being the one used:
And here you have, the latest stable Linux kernel being installed/used by WSL2. The (big) upside of WSL2 is that all the distros are using the same kernel, without any further compilation needed. The (potential) downside is that all share the same configuration.
Looking for SystemD on WSL2
By default, WSL2 does not run SystemD due to the customized init
process. However, a very smart community member, Daniel Llewellyn, made it possible.
Several iterations and alternatives are now available, however in this blog post, I'm using his "one script" as it does not require any additional package to be installed (=less intrusive).
Note: while the kernel is applied to all WSL2 distros, the SystemD install will need to be done for every distro
Let's jump again into the terminal:
And that's it, WSL2 can now be "rebooted" by running the following command in Powershell:
Launch again a terminal with your WSL2 distro, this time you should see a small delay while systemd
is starting.
Once the shell is ready, confirm SystemD is running:
My name is Falco, Kernel module Falco
With everything prepared, the next steps are to follow the Falco documentation, like someone with a "normal" Linux would do. Please remember I'm using Ubuntu and will follow the related section.
However there will be a need for a "detour" related to the Kernel (and not WSL2). Instead of installing the headers from the repo (which did not exist at the time of writing this blog post), we will download them from the Ubuntu kernel website. For any other distro, please check on their respective site.
Note: you can ignore the following errors when installing the Kernel headers packages
W: mkconf: MD subsystem is not loaded, thus I cannot scan for arrays. W: mdadm: failed to auto-generate temporary mdadm.conf file.
Let's jump again into the terminal:
With Falco now installed, there's still some steps needed to "enable and test it". Once again, the Falco documentation is ready and I will follow it here.
One last time (for this blog at least), let's jump into the terminal:
CONGRATULATIONS!!! You have now Falco up and running in WSL2 and ready to be used with your preferred Kubernetes distro (cf. the Falco documentation).
Conclusion
I hope this blog helped you getting Falco into WSL2 and you can now not only test it, but also provide feedback to this wonderful team.
If you have any questions or feedback on Falco, do not hesitate to create an issue on Falco GitHub repo and for WSL2 more specifically, you can reach me on Twitter (@nunixtech)
See you in the Cloud Native seas.
The WSL Corsair