Hardware infrastructure
Octopuce
Octopuce provides hardware managed by the devops team. It can only be accessed via SSH.
To access the services hosted on the LXC containers, ssh port forwarding to the private IPs can be used. For instance:
Containers
It hosts LXC containers setup with lxc-helpers.
-
fogejo-host
Dedicated to http://private.forgejo.org
- LXC creation
- upgrades checklist:
-
fogejo-runner-host
Has runners installed to run against private.forgejo.org
- LXC creation
Hetzner
All hardware is running Debian GNU/linux bookworm.
hetzner01
https://hetzner01.forgejo.org runs on an EX101 Hetzner hardware.
There is no backup, no redundancy and is dedicated to Forgejo runner instances. If the hardware reboots, the runners do not restart automatically, they have to be restarted manually.
It hosts LXC containers setup with lxc-helpers:
-
forgejo-runners
Dedicated to Forgejo runners for the https://codeberg.org/forgejo organization.
-
runner01-lxc
Dedicated to Forgejo runners for the https://code.forgejo.org organization with two labels: docker and self-hosted.
The runners are installed with something like:
hetzner{02,03}
https://hetzner02.forgejo.org & https://hetzner03.forgejo.org run on EX44 Hetzner hardware.
A vSwitch is assigned via the Robot console on both servers and configured in /etc/network/interfaces for each of them with something like:
Root filesystem backups
hetzner03:/etc/cron.daily/backup-hetzner02
rsync -aHS --delete-excluded --delete --numeric-ids --exclude /proc --exclude /dev --exclude /sys --exclude /srv --exclude /var/lib/lxc 10.53.100.2:/ /srv/backups/hetzner02/
hetzner02:/etc/cron.daily/backup-hetzner03
rsync -aHS --delete-excluded --delete --numeric-ids --exclude /proc --exclude /dev --exclude /sys --exclude /srv --exclude /var/lib/lxc 10.53.100.3:/ /srv/backups/hetzner03/
DRBD
DRBD is configured with hetzner02 as the primary and hetzner03 as the secondary:
The DRBD device is mounted on /var/lib/lxc
.
In /etc/fstab
there is a noauto line:
To prevent split brain situations a manual step is required at boot time, on the machine that is going to be the primary, which is hetzner02 in a normal situation.
Fast storage on /srv
The second disk on each node is mounted on /srv and can be used when fast storage is needed and there is no need for backups, such as Forgejo runners.
LXC
LXC is setup with lxc-helpers.
The /etc/default/lxc-net
file is the same on both machines:
Public IP addresses
The public IP addresses attached to the hosts are not failover IPs that can be moved from one host to the next. The DNS entry needs to be updated if the primary hosts changes.
When additional IP addresses are attached to the server, they are added to /etc/network/interfaces
like
65.21.67.71 and 2a01:4f9:3081:51ec::102 below.
Port forwarding
Forwarding a port to an LXC container can be done with /home/debian/code.nftables
for
the public IP of code.forgejo.org (65.21.67.71) to the private IP of the code
LXC container:
with nft -f /root/code.nftables
.
Reverse proxy
The reverse proxy forwards to the designated LXC container with
something like the following in
/etc/nginx/sites-enabled/code.forgejo.org
, where 10.6.83.195 is the
IP allocated to the LXC container running the web service:
The LE certificate is obtained once and automatically renewed with:
Containers
It hosts LXC containers setup with lxc-helpers.
-
fogejo-code
on hetzner02Dedicated to https://code.forgejo.org
- LXC creation
- upgrades checklist:
ssh -t debian@hetzner02.forgejo.org lxc-helpers.sh lxc_container_run forgejo-code -- sudo --user debian bash
ssh -t debian@hetzner02.forgejo.org sudo /etc/cron.daily/backup-forgejo-code
ssh -t debian@hetzner02.forgejo.org lxc-helpers.sh lxc_container_run forgejo-code -- sudo --user debian bash
- Rotating 30 days backups happen daily
/etc/cron.daily/forgejo-code-backup.sh
- Add code.forgejo.org to the forgejo.org SPF record
-
forgejo-next
on hetzner02Dedicated to https://next.forgejo.org
- LXC creation same as code.forgejo.org
/etc/cron.hourly/forgejo-upgrade
runs/home/debian/run-forgejo.sh > /home/debian/run-forgejo-$(date +%d).log
- When a new major version is published (8.0 for instance)
run-forgejo.sh
must be updated with it - Reset everything
/home/debian/next.nftables
- Add to
iface enp5s0 inet static
in/etc/network/interfaces
-
forgejo-v7
on hetzner02Dedicated to https://v7.next.forgejo.org
- LXC creation same as code.forgejo.org
/etc/cron.hourly/forgejo-upgrade
runs/home/debian/run-forgejo.sh > /home/debian/run-forgejo-$(date +%d).log
- Reset everything
/home/debian/v7.nftables
- Add to
iface enp5s0 inet static
in/etc/network/interfaces
-
runner-forgejo-helm
on hetzner03Dedicated to https://codeberg.org/forgejo-contrib/forgejo-helm and running from an ephemeral disk
Uberspace
The website https://forgejo.org is hosted at https://uberspace.de/. The https://codeberg.org/forgejo/website/ CI has credentials to push HTML pages there.
ubuntu-runner.forgejo.org
The ubuntu-runner.forgejo.org virtual machine is hosted in the OVH public cloud under the same account as the domain names. It is dedicated to a Forgejo runner for the benefit of the snap package of Forgejo.
As of April 2024 it is unclear how to run snapd in an LXC nested container. When this is resolved, the machine can be destroyed and the runner moved to an LXC container instead.
Forgejo contributors with SSH access to this machine are:
Installing Forgejo runners
Preparing the LXC hypervisor
Creating an LXC container
Creating a runner
Multiple runners can co-exist on the same machine. To keep things organized they are located in a directory that is the same as the url from which the token is obtained. For instance DIR=codeberg.org/forgejo-integration means that the token was obtained from the https://codeberg.org/forgejo-integration organization.
If a runner only provides unprivileged docker containers, the labels
in config.yml
should be:
labels: ['docker:docker://node:20-bookworm']
.
If a runner provides LXC containers and unprivileged docker
containers, the labels in config.yml
should be
labels: ['self-hosted:lxc://debian:bookworm', 'docker:docker://node:20-bookworm']
.
codeberg.org config.yml
fetch_timeout: 30s
# because it can be slow at timesfetch_interval: 60s
# because there is throttling and 429 replies will mess up the runner