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

v2.1.0 #219

Merged
merged 38 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
f87e372
Fix removal of resolv.conf
Jip-Hop Jun 23, 2024
2ce89c2
Fix removal of immutable/append-only files
Jip-Hop Jun 23, 2024
74e717a
Fix comment in config templates
Jip-Hop Jun 23, 2024
804be6d
Put initial_setup script in jail root
Jip-Hop Jun 24, 2024
49d65c1
Fix case
Jip-Hop Jun 24, 2024
51884e2
Parse os-release in chroot
Jip-Hop Jun 24, 2024
7832b17
Detect init system in chroot
Jip-Hop Jun 24, 2024
32143a9
Add support for nixos
Jip-Hop Jun 24, 2024
1fa69d6
Bump version to 2.1.0
Jip-Hop Jun 24, 2024
dd30ffe
Chroot with contextmanager
Jip-Hop Jun 24, 2024
2841137
Copy resolv.conf on first start
Jip-Hop Jun 24, 2024
1b796ca
Added passing arguments to log and status
Lockszmith-GH Jun 27, 2024
1bd58c9
Cleanup log and status code
Jip-Hop Jun 28, 2024
e1f1d07
Remove debug logging
Jip-Hop Jun 28, 2024
01e1156
Accept config template from stdin
Jip-Hop Jun 28, 2024
21efe90
Fix Python 3.12 SyntaxWarning
Jip-Hop Jun 29, 2024
a67e239
Merge branch 'main' into develop
Jip-Hop Jun 29, 2024
13f8a67
Cleanup networking docs
Jip-Hop Jul 3, 2024
742a70b
Add a simple router template (#216)
jonct Jul 5, 2024
9da33ab
Stay in workdir
Jip-Hop Jul 3, 2024
2d3ae20
Prepare resources in the GitHub action for test scripts (#220)
jonct Jul 8, 2024
762b83a
Cast int to string
Jip-Hop Jul 9, 2024
9fcb5d5
Add TODO
Jip-Hop Jul 9, 2024
ef595e5
Test podman
Jip-Hop Jul 9, 2024
434e195
Automated testing script (#215)
Lockszmith-GH Jul 9, 2024
49b5bf2
Add readme
Jip-Hop Jul 9, 2024
90fa274
Run both test scripts for now
Jip-Hop Jul 9, 2024
be51af6
Test with docker again
Jip-Hop Jul 9, 2024
29cb1ee
Cleanup jail if lxc download script fails
Jip-Hop Jul 9, 2024
414df22
Formatting
Jip-Hop Jul 9, 2024
45df5d6
Add debug output
Jip-Hop Jul 9, 2024
c7b79c7
Debug logging
Jip-Hop Jul 9, 2024
345eee3
Add systemctl
Jip-Hop Jul 9, 2024
39e7fc6
Remove systemctl
Jip-Hop Jul 9, 2024
b8ce9c4
Debugging
Jip-Hop Jul 9, 2024
d0a532f
Fix systemd_nspawn_user_args override
Jip-Hop Jul 9, 2024
9690a5a
Remove debug logging
Jip-Hop Jul 9, 2024
32843da
Fix systemd_nspawn_user_args override
Jip-Hop Jul 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 68 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ name: CI
on:
# Triggers the workflow on push or pull request events for any branch
push:
branches: [ "**" ]
branches: ["**"]
pull_request:
branches: [ "**" ]
branches: ["**"]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
test:
# The type of runner that the job will run on
runs-on: ubuntu-24.04

Expand All @@ -25,6 +25,68 @@ jobs:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4

# Runs a single command using the runners shell
- name: Run a one-line script
run: sudo ./test/test.sh
- name: Tune GitHub-hosted runner network
uses: smorimoto/tune-github-hosted-runner-network@v1

# Create a network namespace in the GitHub-hosted runner VM,
# simulating a primary bridge network on TrueNAS SCALE
- name: Set up networking resources
run: |
sudo -s <<END

systemctl disable systemd-resolved --now
rm /etc/resolv.conf
echo 'nameserver 1.1.1.1' > /etc/resolv.conf

apt-get install -qq -y systemd-container

cat <<NETWORKCONFIG >/etc/systemd/network/10-br1.network
[Match]
Kind=bridge
Name=br1

[Network]
# Default to using a /24 prefix, giving up to 253 addresses per virtual network.
Address=0.0.0.0/24
LinkLocalAddressing=yes
DHCPServer=yes
IPMasquerade=both
LLDP=yes
EmitLLDP=customer-bridge
IPv6AcceptRA=no
IPv6SendRA=yes
NETWORKCONFIG

systemctl restart systemd-networkd
ip link add name br1 type bridge

iptables -I DOCKER-USER -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
iptables -I DOCKER-USER -i br1 -o eth0 -j ACCEPT
END

- name: Examine the GitHub-hosted runner environment
run: |
uname -r
cat /etc/os-release
python3 --version
ip addr

# # TODO: create zpool with virtual disks, create jailmaker dataset and test jlmkr.py from there
# # https://medium.com/@abaddonsd/zfs-usage-with-virtual-disks-62898064a29b
# - name: Create a parent ZFS dataset
# run: |
# sudo -s <<END
# apt-get install -y -qq zfsutils-linux
# modinfo zfs | grep version
# zfs --version
# zpool --version
# END

# Run multiple commands using the runners shell
- name: Run the test script
env:
PYTHONUNBUFFERED: 1
run: |
sudo chown 0:0 jlmkr.py ./test/test-jlmkr
sudo bash ./test/test-jlmkr
sudo ./test/test.sh
1 change: 1 addition & 0 deletions docs/compatibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
|Debian 12 Bookworm|✅|
|Ubuntu Jammy|✅|
|Fedora 39|✅|
|Nixos 24.05|✅|
|Arch|🟨|
|Alpine|❌|

Expand Down
8 changes: 4 additions & 4 deletions docs/network.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Add the `--network-bridge=br1 --resolv-conf=bind-host` systemd-nspawn flag when
The TrueNAS host and the jail will be able to communicate with each other as if the jail was just another device on the LAN. It will use the same DNS servers as the TrueNAS host because the `--resolv-conf=bind-host` option bind mounts the `/etc/resolv.conf` file from the host inside the jail. If you want to use the DNS servers advertised via DHCP, then check [DNS via DHCP](#dns-via-dhcp).

### Bridge Static IP
To configure a static IP with our bridge interface, we need to edit the `/etc/systemd/network/80-container-host0.network` file. Change the [Network] section to look like this:
To configure a static IP with our bridge interface, we need to edit the `/etc/systemd/network/80-container-host0.network` file. Change the [Network] section to look like this:

```ini
[Network]
Expand All @@ -43,14 +43,14 @@ ifconfig
```

### Multiple Bridge Interfaces
[Systemd-nspawn](https://www.freedesktop.org/software/systemd/man/latest/systemd-nspawn.html), the technology on which jailmaker is built, [currently](https://github.com/systemd/systemd/issues/11087) only supports the definition and automatic configuration of a single bridge interface via the [`--network-bridge`](https://www.freedesktop.org/software/systemd/man/latest/systemd-nspawn.html#--network-bridge=) argument. In some cases however, for instance when trying to utilize different vlan interfaces, it can be useful to configure multiple bridge interfaces within a jail. It is possible to create extra interfaces and join them to host bridges manually with systemd-nspwan using a combination of the [`--network-veth-extra`](https://www.freedesktop.org/software/systemd/man/latest/systemd-nspawn.html#--network-veth-extra=) argument and a service config containing `ExecStartPost` commands as outlined [here](https://wiki.csclub.uwaterloo.ca/Systemd-nspawn#Multiple_network_interfaces).
[Systemd-nspawn](https://www.freedesktop.org/software/systemd/man/latest/systemd-nspawn.html), the technology on which jailmaker is built, [currently](https://github.com/systemd/systemd/issues/11087) only supports the definition and automatic configuration of a single bridge interface via the [`--network-bridge`](https://www.freedesktop.org/software/systemd/man/latest/systemd-nspawn.html#--network-bridge=) argument. In some cases however, for instance when trying to utilize different vlan interfaces, it can be useful to configure multiple bridge interfaces within a jail. It is possible to create extra interfaces and join them to host bridges manually with systemd-nspwan using a combination of the [`--network-veth-extra`](https://www.freedesktop.org/software/systemd/man/latest/systemd-nspawn.html#--network-veth-extra=) argument and a service config containing `ExecStartPost` commands as outlined [here](https://wiki.csclub.uwaterloo.ca/Systemd-nspawn#Multiple_network_interfaces).

The `--network-veth-extra` argument instructs system-nspawn to create an addition linked interface between the host and jail and uses a syntax of
```
--network-veth-extra=<host_interface_name>:<jail_interface_name>
```

The service config constaining `ExecStartPost` commands is then used to add the host side of the interface link to an existing host bridge and bring the interface up. Jailmaker has simplified this process by including a `post_start_hook` configuration parameter which can automate the creation of the service config by including the `ExecStartPost` commands as below.
The service config `ExecStartPost` commands is then used to add the host side of the interface link to an existing host bridge and bring the interface up. Jailmaker has simplified this process by including a `post_start_hook` configuration parameter which can automate the creation of the service config by including the `ExecStartPost` commands as below.

```
post_start_hook=#!/usr/bin/bash
Expand All @@ -62,7 +62,7 @@ post_start_hook=#!/usr/bin/bash
ip link set dev ve-docker-2 up
```

With the new `--network-veth-extra` interface link created and the host side added to an existing host bridge, the jail side of the link still needs to be configured. Jailmaker provides a network file in the form of `/etc/systemd/network/vee-dhcp.network` which will automatically perform this configuration. In order for `vee-dhcp.network` to successfully match and configure the link's jail side interface, the `<jail_interface_name>` must begin with a ***vee-*** prefix. An example jailmaker config with properly named `--network-veth-extra` interfaces and `post_start_hook` commands is available [here](https://github.com/Jip-Hop/jailmaker/discussions/179#discussioncomment-9499289).
With the new `--network-veth-extra` interface link created and the host side added to an existing host bridge, the jail side of the link still needs to be configured. Jailmaker provides a network file in the form of `/etc/systemd/network/vee-dhcp.network` which will automatically perform this configuration. In order for `vee-dhcp.network` to successfully match and configure the link's jail side interface, the `<jail_interface_name>` must begin with a ***vee-*** prefix. An example jailmaker config with properly named `--network-veth-extra` interfaces and `post_start_hook` commands is available [here](https://github.com/Jip-Hop/jailmaker/discussions/179#discussioncomment-9499289).

## Macvlan Networking

Expand Down
Loading