Freebsd way into the clouds.
The most optimal way of hosting your services in cloud depends on needs of those services.
And because of that, there is no "best" solution (for everyone), there is a solution that suits *your* needs the most.
So, what i will try to do in this article, is to just list the different solutions and approaches of hosting services in cloud using Freebsd.
As i have been only working with AWS as cloud provider, this article will be AWS specific, but the concept of solutions provided should be the same for other cloud providers.
The main reason of this article, is really to just start conversation with interested people about using Freebsd in cloud, approaches of doing so, solutions, ideas, dreams and etc...
Possible ways of hosting in cloud
I know that it sounds quite obvious, but firstly lets have a small look into the possible ways of utilizing cloud providers to host our services:
I) Bare-metal
You can have an Freebsd OS up an running on a "bare/clean" hardware of the cloud-provider. This approach is basically the same as if you would host services on your own hardware (that you would rent), with some additions:
You can use VM's in cloud.
AWS provides you an service "EC2" to get access to virtual machines with Freebsd as OS.
By the containers hosted in Freebsd, of course, i mean jails.
There is a number of tools for managing jails, but about them later.
By the containers hosted in Freebsd, of course, i mean jails.
Depends on your needs, you might would want to host containers not on the VM, but on the bare-metal.
That might be a case, if you would want all of the containers to be on one physical instance.
Jail management tools (with orchestration)
Now i will try to list jail-management tools, possible orchestration ways, and my humble overview of them:
1) Firecracker with Freebsd microvm's + kubernetes
Firecracker with Freebsd + containerd + kubernetes in all of my testings did not work.
I have spent a lot of time and brain cells on finding out what, where and how it even should be working.
By connecting information from several tutorials, i was able to come close to make it work in one of the possible approaches, but now it requires some changes to one of the tools (kata-containers) code (in golang).
If to be more specific:
Firstly, i went trough this tutorial , which uses "Firecracker with PHV support" provided by Colin Percival here , to setup Firecracker linux host, to host Freebsd VM's.
What i have tried then is to connect: Firecracker-Freebsd, Firecracker-kata'containers, kata'containers-containerd, containerd-kubelet, by the tutorials provided by kata-containerd authors, those mentioned at the end of this topic.
The issue is in kata-containers code, as it needs to generate specific configuration file when calling Firecracker, i have created ticket, and got pointed to the code, where i can modify it, to build my own custom kata-containers, that maybe will work. But, by that point i would say that this approach is not very ready. **All of the tutorials, on how to use kata-containers with containerd, EVEN ON ON THEIR OFFICIAL GITHUB, are outdated, so they dont work out of the box (that made me to lose some brain cells for sure), so be ready to suffer if you go this path...
There is another approach/project to test out though, that i for some reason missed - https://github.com/firecracker-microvm/firecracker-containerd/blob/main/docs/getting-started.md .
As far as i have understood, Firecracker creators themself have created a "runtime shim" to make Firecracker to work with containerd, which might work with the Firecracker that works with Freebsd.
In the end, even by just following the guide provided (above) in github by the creators of this containerd-firecracker-shim i was just receving an error:
Which i was not able to fix, as it is claimed that the project is in "very early state" of development, i would guess that the documentation is not up to date (at least, at the time when i was doing my tests).
Creating Firecracker that would work with Freebsd : https://morezerosthanones.com/posts/firecracker_freebsd/
Firecracker - kata-containers : https://github.com/kata-containers/...ow-to-use-kata-containers-with-firecracker.md
kata-containers - containerd : https://github.com/kata-containers/documentation/blob/master/how-to/containerd-kata.md
containerd - kubernetes : https://github.com/kata-containers/...to/how-to-use-k8s-with-containerd-and-kata.md
Firecracker - containerd : https://github.com/firecracker-microvm/firecracker-containerd
In the end, this approach looks very promising, but:
* Firecracker should work on the Freebsd as host.
* Firecracker should work with containerd.
* We would need to test Freebsd "microVM's" performance, and be pleased with the results.
If all of those above would come true, not only this tool would be very useful for on premises, Freebsd also would be able to fight for a place in clouds .
2) CBSD+puppet
As i see the approach using this tool:
1) Creating EC2 AMI for puppet server and client - puppet server AMI should have puppetserver installed, and client should have puppet agent + CBSD module + CBSD itself installed.
2) Using those AMI and terraform code create infrastructure
2.1) Call terraform, which will build EC2 instances, connect puppet server and client, move puppet manifest, call puppet run on client, which will contain CBSD code to create needed jails?
3) Using puppet code, call for the agent's to create jails, with your applications inside of it.
4) To update... run puppet
3) Nomad + pot
1) Create an EC2 AMI, with Nomad and pot installed in it
2) Create an pot image, with application, binaries, whatever you need preinstalled, host it whenenever terraform will be able to get them
3) Create terraform manifest, that would build EC2 instance, start nomad client and server, and will push nomad job with the pot-task-driver.
4) Run terraform
5) Ta-da, you got an EC2 Freebsd instance, with jails in them, with applications running inside of the jails.... cool.
4) iocage
There might be even more of them, and there will be in future, but more time needed to look at all of them, and even more time to actually understand what is the difference between all of them. This article is not a "truth stuck in static", this article is a process, which will get more and more informative with the flow of time (hopefully?), with the input from community, with development of mentioned above tools, and maybe inventions of new ones.
The end
What are your thoughts? What are the tools that i have not mentioned, should be mentioned? At what tools i should take a look? What do you think of taking Freebsd into the clouds as an idea? Maybe someone already did it, and might want to share experience?
P.S
1) some "non biased"? comparison from BastilleBSD website https://bastillebsd.org/compare/ (includes 2022 info only?)
2) Some person claims that by 2023 only BastilleBSD, pot/nomad, CBSD, and plain jail.conf(5) nad jail(8) can be used. https://forums.freebsd.org/threads/...jail-cbsd-pot-iocage-ezjail.86656/post-596707 , and other options are ... out of option, because of "not being updated for long time", tho i have seen somewhere - some person, saying that ezjail is not "left without updates", but it is just already finished project with everything already implemented.. heh.
3) There is a chart of Freebsd jail manager life/timeline by 2023 https://www.bsdstore.ru/img/freebsd-jail-chart-2022.png
4) If you are interested in topic of this article, check out this talk on EuroBSDCon
5) All things written above are not "the ultimate truth".
The most optimal way of hosting your services in cloud depends on needs of those services.
And because of that, there is no "best" solution (for everyone), there is a solution that suits *your* needs the most.
So, what i will try to do in this article, is to just list the different solutions and approaches of hosting services in cloud using Freebsd.
As i have been only working with AWS as cloud provider, this article will be AWS specific, but the concept of solutions provided should be the same for other cloud providers.
The main reason of this article, is really to just start conversation with interested people about using Freebsd in cloud, approaches of doing so, solutions, ideas, dreams and etc...
Possible ways of hosting in cloud
I know that it sounds quite obvious, but firstly lets have a small look into the possible ways of utilizing cloud providers to host our services:
I) Bare-metal
You can have an Freebsd OS up an running on a "bare/clean" hardware of the cloud-provider. This approach is basically the same as if you would host services on your own hardware (that you would rent), with some additions:
II) VM+ you always can "kill" the server, and stop using it, so you basically rent out the hardware on the basis of your present needs.
+ You get access to use some additional services provided by the cloud provider, that work only with cloud provider own hosted hardware.
- If you dont need 128GB of RAM, or 64 thread processor, then this approach would be using resources non-efficiently, as cloud providers (AWS) give as an option of "bare-metal" only such powerfull servers (and
so the price is high - ~5$ an hour).
You can use VM's in cloud.
AWS provides you an service "EC2" to get access to virtual machines with Freebsd as OS.
III) Containers in VM.+ VM's are more secure way of hosting services than the bare-metal and container approaches. (Thought, that might be debatable?)
+ - microVM's might be as fast as containers (debatable?).
By the containers hosted in Freebsd, of course, i mean jails.
There is a number of tools for managing jails, but about them later.
IV) Containers in bare-metal+ containers are the fastest way of creating new instance with your new application (with the interest in microVM's rising... debatable?).
+ Scalable in fast manner (in difference with VM's and bare-metal)
+ more effecient usage of hardware (than VM, because of hypervisor? might be also debatable i guess.)
- less secure than VM's (on avarage?)
By the containers hosted in Freebsd, of course, i mean jails.
Depends on your needs, you might would want to host containers not on the VM, but on the bare-metal.
That might be a case, if you would want all of the containers to be on one physical instance.
- More expensive
+ might be the only applicable approach for some of the jail-management tools (if you really want to use those).
Jail management tools (with orchestration)
Now i will try to list jail-management tools, possible orchestration ways, and my humble overview of them:
1) Firecracker with Freebsd microvm's + kubernetes
Firecracker with Freebsd + containerd + kubernetes in all of my testings did not work.
I have spent a lot of time and brain cells on finding out what, where and how it even should be working.
By connecting information from several tutorials, i was able to come close to make it work in one of the possible approaches, but now it requires some changes to one of the tools (kata-containers) code (in golang).
If to be more specific:
Firstly, i went trough this tutorial , which uses "Firecracker with PHV support" provided by Colin Percival here , to setup Firecracker linux host, to host Freebsd VM's.
What i have tried then is to connect: Firecracker-Freebsd, Firecracker-kata'containers, kata'containers-containerd, containerd-kubelet, by the tutorials provided by kata-containerd authors, those mentioned at the end of this topic.
The issue is in kata-containers code, as it needs to generate specific configuration file when calling Firecracker, i have created ticket, and got pointed to the code, where i can modify it, to build my own custom kata-containers, that maybe will work. But, by that point i would say that this approach is not very ready. **All of the tutorials, on how to use kata-containers with containerd, EVEN ON ON THEIR OFFICIAL GITHUB, are outdated, so they dont work out of the box (that made me to lose some brain cells for sure), so be ready to suffer if you go this path...
There is another approach/project to test out though, that i for some reason missed - https://github.com/firecracker-microvm/firecracker-containerd/blob/main/docs/getting-started.md .
As far as i have understood, Firecracker creators themself have created a "runtime shim" to make Firecracker to work with containerd, which might work with the Firecracker that works with Freebsd.
In the end, even by just following the guide provided (above) in github by the creators of this containerd-firecracker-shim i was just receving an error:
temporary vsock dial failure: vsock ack message failure: failed to read \"OK <port>\
Which i was not able to fix, as it is claimed that the project is in "very early state" of development, i would guess that the documentation is not up to date (at least, at the time when i was doing my tests).
Creating Firecracker that would work with Freebsd : https://morezerosthanones.com/posts/firecracker_freebsd/
Firecracker - kata-containers : https://github.com/kata-containers/...ow-to-use-kata-containers-with-firecracker.md
kata-containers - containerd : https://github.com/kata-containers/documentation/blob/master/how-to/containerd-kata.md
containerd - kubernetes : https://github.com/kata-containers/...to/how-to-use-k8s-with-containerd-and-kata.md
Firecracker - containerd : https://github.com/firecracker-microvm/firecracker-containerd
In the end, this approach looks very promising, but:
* Firecracker should work on the Freebsd as host.
* Firecracker should work with containerd.
* We would need to test Freebsd "microVM's" performance, and be pleased with the results.
If all of those above would come true, not only this tool would be very useful for on premises, Freebsd also would be able to fight for a place in clouds .
2) CBSD+puppet
GitHub - cbsd/cbsd: Yet one more wrapper around jail, bhyve, QEMU and XEN
Yet one more wrapper around jail, bhyve, QEMU and XEN - cbsd/cbsd
github.com
+ puppet and bash = stability, good support, experience.
+ easy to add scripts/modules on top of it, as it uses bash + puppet + ssh (https://www.bsdstore.ru/en/node_cbsd.html) to work with client nodes.
+ community involvment looks overall good
- very... very bad documentation (most of the articles or videos are in russian, and then poorly translated into english)
- images... are not images in sense of "box with everything preinstalled", it is more an "script that builds that box we call container". https://www.bsdstore.ru/ru/articles/cbsd_puppet_jail_images.html
- No integration with different cloud providers services
- No market would want a product with such tool being in use (as... overall with BSD? if of course you are not hosting it yourself and customer does not care how you do it).
As i see the approach using this tool:
1) Creating EC2 AMI for puppet server and client - puppet server AMI should have puppetserver installed, and client should have puppet agent + CBSD module + CBSD itself installed.
2) Using those AMI and terraform code create infrastructure
2.1) Call terraform, which will build EC2 instances, connect puppet server and client, move puppet manifest, call puppet run on client, which will contain CBSD code to create needed jails?
3) Using puppet code, call for the agent's to create jails, with your applications inside of it.
4) To update... run puppet
3) Nomad + pot
GitHub - bsdpot/nomad-pot-driver: Nomad task driver for launching freebsd jails.
Nomad task driver for launching freebsd jails. Contribute to bsdpot/nomad-pot-driver development by creating an account on GitHub.
github.com
As i see, this tools being in use in cloud (and i actually tested it, worked cool):+ thats what the Yan Ka Chiu recommended to use in his EuroBSDcon 2022 talk \-\ https://papers.freebsd.org/2022/eurobsdcon/chiu-freebsd_containers_in_production/
+ Jails are Scalable and orchestratable with the help of Nomad and Consul
- pot is not OCI compatible, which means we will need to create very "pot" specific images, which means that if we will want to move to some other "jail driver"/"container runtime" we would need to create new images.
+ Nomad, Consul and pot seems to be getting proper support. (nomad is hashicorp product (terraform guys), and pot was lastly updated 3 months ago... good?)
1) Create an EC2 AMI, with Nomad and pot installed in it
2) Create an pot image, with application, binaries, whatever you need preinstalled, host it whenenever terraform will be able to get them
3) Create terraform manifest, that would build EC2 instance, start nomad client and server, and will push nomad job with the pot-task-driver.
4) Run terraform
5) Ta-da, you got an EC2 Freebsd instance, with jails in them, with applications running inside of the jails.... cool.
4) iocage
GitHub - iocage/iocage: A FreeBSD jail manager written in Python 3
A FreeBSD jail manager written in Python 3. Contribute to iocage/iocage development by creating an account on GitHub.
github.com
5) BastilleBSD- Jails are "state preserving", and we dont want them to be like that (by Yan Ka Chiu in here )
- No possibility to orchestrate multiple instances at the same time? and so poor scalability?
- Python dependency
- not supported anymore? latest release 2019 - https://github.com/iocage/iocage/releases
GitHub - BastilleBSD/bastille: Bastille is an open-source system for automating deployment and management of containerized applications on FreeBSD.
Bastille is an open-source system for automating deployment and management of containerized applications on FreeBSD. - BastilleBSD/bastille
github.com
6) runj- Jails are "state preserving", and we dont want them to be like that it to be like that in cloud (from the words of Yan Ka Chiu). In 2022 EuroBSDcon talk Yan Ka Chiu said "Bastille is kinda out of question" (as i have understood, he meant it is out of question for using it in cloud --_(-_-)_-- ) - here (we really need to work on sound for BSDcons, cant understand half of the things )
+ open for community input
+ they have bastille file, which is kinda the same as docker file, which is cool.
- No orchestration/clusterization capabilities (for now?), asked in this git ticket.
GitHub - samuelkarp/runj: runj is an experimental, proof-of-concept OCI-compatible runtime for FreeBSD jails.
runj is an experimental, proof-of-concept OCI-compatible runtime for FreeBSD jails. - GitHub - samuelkarp/runj: runj is an experimental, proof-of-concept OCI-compatible runtime for FreeBSD jails.
github.com
7) XC (by Yan Ka Chiu)- not production ready (as stated by the author https://github.com/samuelkarp/runj#runj).
- Personal project (does not *really* accept community input)
+ OCI compatible (will work with kubernetes). Works with "containerd", which in its turn is CRI compatible which means it works with kubernetes... cool.
GitHub - michael-yuji/xc: FreeBSD container engine
FreeBSD container engine. Contribute to michael-yuji/xc development by creating an account on GitHub.
github.com
∞)(insert tool name)- not production ready (as stated by the author).
+ Open for community input.
+ Created by the Yan Ka Chiu guy, who had at least 2 related to "containers in Freebsd" talks at euro EuroBSDcon, and at 2023, when he have presented it, the functionality looked very cool for me - here
- There is no orchestration tool that works with it? Not CRI compatible, and as i remember, when i asked him about CRI support, he stated that it is *not* in short term plans.
+ OCI compatible, which means (most of?) linux docker images will work with this tool.
There might be even more of them, and there will be in future, but more time needed to look at all of them, and even more time to actually understand what is the difference between all of them. This article is not a "truth stuck in static", this article is a process, which will get more and more informative with the flow of time (hopefully?), with the input from community, with development of mentioned above tools, and maybe inventions of new ones.
The end
What are your thoughts? What are the tools that i have not mentioned, should be mentioned? At what tools i should take a look? What do you think of taking Freebsd into the clouds as an idea? Maybe someone already did it, and might want to share experience?
P.S
1) some "non biased"? comparison from BastilleBSD website https://bastillebsd.org/compare/ (includes 2022 info only?)
2) Some person claims that by 2023 only BastilleBSD, pot/nomad, CBSD, and plain jail.conf(5) nad jail(8) can be used. https://forums.freebsd.org/threads/...jail-cbsd-pot-iocage-ezjail.86656/post-596707 , and other options are ... out of option, because of "not being updated for long time", tho i have seen somewhere - some person, saying that ezjail is not "left without updates", but it is just already finished project with everything already implemented.. heh.
3) There is a chart of Freebsd jail manager life/timeline by 2023 https://www.bsdstore.ru/img/freebsd-jail-chart-2022.png
4) If you are interested in topic of this article, check out this talk on EuroBSDCon
5) All things written above are not "the ultimate truth".