Add POC for OCI jails - #1619
Open
tschettervictor wants to merge 34 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
FEAT: Support for creating a jail based entirely on an OCI image. This is POC and experimental, so give it a go.
To get started, verify you have the following variable set in
/usr/local/etc/bastille.conf:bastille_volumesdir="${bastille_prefix}/volumes"To create an OCI jail, use the new
-O|--ociflag when creating a new jail. Additional options include:-e KEY=VALUEto pass environment variables to the jail (repeatable)--data-path PATHto specify a location for persistent data--os OSto pull non-freebsd images (eg:--os Linux)Bastille extracts most information from the image itself, and stores important info inside the jail conf directory. This includes things like volume mounts, entrypoint, labels, env vars, start cmd, stop signal, and a few more. Because it knows the volumes it needs to mount, you need not worry about persistent data, unless you want to store it somewhere other that
${bastille_volumesdir}Creating an OCI jail using the create sub-command
To create an OCI jail using the navidrome image from daemonless.io, run the following command:
Notice that instead of the RELEASE, we simply specify an image name. This will fetch the image, extract it into the jail, and configure jail.conf to launch the entrypoint on startup.
The image pulled will always be latest. For now, if you want to update an image, simply destroy the jail and rebuild it. All persistent data is stored either in your custom directory (if
--data-pathwas given at create) or at${bastille_volumesdir}It is possible to create a VNET jail using this method with either
-Bor-Vand the app should run fine. Just note that you do not have to forward any ports for VNET jails.It is also possible to pull linux images using the
--os linuxflag. Tested with docker.io/filebrowser/filebrowser but don't expect support for them, as even though some will work, they are not supported on FreeBSD.The following examples all work in testing:
Notice that for opencloud you need to specify your host IP as the OC_URL instead of the jail IP. Opencloud in finicky in this way.
Creating an OCI jail using the up sub-command
In addition to these, a new sub-command has been added.
bastille upwill attempt to deploy an OCI image from apodman-compose.ymlfile in the current working directory.Some things to note for
bastille up:bastille upfrom the $PWD, so make sure you are in the directory that has the compose file${bastille_prefix}/volumes/${JAIL}or--data-pathso you don't have to worry about thatinheritif podman-compose hasnetwork_mode: host. Change tonetwork_mode: 10.34.34.34to use that specific IP for that specific container--data-pathinbastille upto specify a non-default path. (Don't include the jail name here, only the top level path like/usr/local/apps.envfile in the directory where the podman-compose file is, and use the values inside it to replace any instances of a given variable in the compose file. See the following example:Taken from https://github.com/daemonless/audiobookshelf
podman-compose.yml
.env
Simply enter the directory where these file are located and run
bastille upNot all annotations of the compose file are supported. For example, Bastille stores all persistent data a
${bastille_volumesdir}regardless of thevolumes:annotation in the compose file. Most options should be supported, but not all are used. The parser will create abastille-compose.conffile next to thepodman-compose.ymlfile in the following format. Fore each indentation, we simply add one level. For example,environment:in the example above will read:We use
:to better handle env vars when building the create command that will be run at the end of thebastille uproutine.Notes
This is still experimental, and code standardization will need to be figured out. This includes the jails structure, as well as the jail.conf file and any additional flags to add.