Hardware infrastructure
The resources used by the infrastructure are in the https://code.forgejo.org/infrastructure/ organization. There is a dedicated chatroom.
LXC Hosts
All LXC hosts are setup with lxc-helpers.
See https://github.com/mikesart/inotify-info. Running multiple LXC containers will quickly use the default limit (128 on bookworm).
Unprivileged
Docker enabled
K8S enabled
Docker and LXC enabled
nftables
Host reverse proxy
The reverse proxy on a host forwards to the designated LXC container with
something like the following examples in
/etc/nginx/sites-available/example.com
, where A.B.C.D is the
IP allocated to the LXC container running the web service.
And symlink:
The certificate is obtained once and automatically renewed with:
When removing a configuration, the certificate can also be removed with:
Host wakeup-on-logs
https://code.forgejo.org/infrastructure/wakeup-on-logs
K8S wakeup-on-logs script
Forgejo example
GitLab example
Vanila example
302 redirection
Forgejo runners
The LXC container in which the runner is installed must have capabilities that support the backend.
- docker:// needs a Docker enabled container
- lxc:// needs a Docker and LXC enabled container
The runners it contains are not started at boot, it must be done manually. The bash history has the command line to do so.
Installation
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']
.
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
-
fogejo-host
Dedicated to http://private.forgejo.org
- Docker enabled
- upgrades checklist:
-
fogejo-runner-host
Has runners installed to run against private.forgejo.org
- Docker and LXC enabled 10.85.12 fc33
Hetzner
All hardware machines are running Debian GNU/linux bookworm. They are LXC hosts setup with lxc-helpers.
NOTE: only use EX101 with a ASRockRack W680D4U-1L motherboard.
vSwitch
A vSwitch is assigned via the Robot console on all servers for backend communications and configured in /etc/network/interfaces for each of them with something like:
The IP address ends with the same number as the hardware (hetzner02 => .2).
DRBD
DRBD is configured like in the following example with hetzner02 as the primary and hetzner03 as the secondary:
On hetzner02 (the primary), pretend all is in sync to save the initial bitmap sync since there is actually no data at all.
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.
hetzner{01,04}
https://hetzner{01,04}.forgejo.org run on EX101 Hetzner hardware.
LXC
Disk partitioning
- First disk
- OS
- a partition mounted on /srv where non precious data goes such as the LXC containers with runners.
- Second disk
- configured with DRBD for precious data.
Root filesystem backups
hetzner01:/etc/cron.daily/backup-hetzner04
rsync -aHS --delete-excluded --delete --numeric-ids --exclude /proc --exclude /dev --exclude /sys --exclude /precious --exclude /srv --exclude /var/lib/lxc 10.53.100.4:/ /srv/backups/hetzner04/ >& /var/log/$(basename $0).log
hetzner04:/etc/cron.daily/backup-hetzner01
rsync -aHS --delete-excluded --delete --numeric-ids --exclude /proc --exclude /dev --exclude /sys --exclude /precious --exclude /srv --exclude /var/lib/lxc 10.53.100.1:/ /srv/backups/hetzner01/ >& /var/log/$(basename $0).log
LXC containers
-
runner-lxc-helpers
(hetzner01)Dedicated to Forgejo runners for the https://code.forgejo.org/forgejo/lxc-helpers project.
- K8S enabled
- code.forgejo.org/forgejo/lxc-helpers/config*.yml
-
forgejo-runners
(hetzner01)Dedicated to Forgejo runners for the https://codeberg.org/forgejo organization.
- Docker enabled
- codeberg.org/forgejo/config*.yml
-
runner01-lxc
(hetzner01)Dedicated to Forgejo runners for https://code.forgejo.org.
- Docker and LXC enabled 10.194.201 fc35
- code.forgejo.org/forgejo/config*.yml
- code.forgejo.org/actions/config*.yml
- code.forgejo.org/forgejo-integration/config*.yml
- code.forgejo.org/forgejo-contrib/config*.yml
- code.forgejo.org/f3/config*.yml
- code.forgejo.org/forgefriends/config*.yml
-
forgejo-v9
(hetzner04) same asforgejo-v8
-
forgejo-v8
(hetzner04)Dedicated to https://v8.next.forgejo.org
- K8S enabled
- K8S wakeup-on-logs script /etc/wakeup-on-logs/forgejo-v8
- Values file
/home/debian/v8.nftables
- Add to
iface enp4s0 inet static
in/etc/network/interfaces
-
forgefriends-forum
(hetzner04)Dedicated to https://forum.forgefriends.org
- Docker enabled
-
forgefriends-gitlab
(hetzner04)Dedicated to https://lab.forgefriends.org
- Docker enabled
-
forgefriends-cloud
(hetzner04)Dedicated to https://cloud.forgefriends.org
- Docker enabled
-
gna-forgejo
(hetzner04)Dedicated to https://forgejo.gna.org
- Docker enabled
-
gna-forum
(hetzner04)Dedicated to https://forum.gna.org
- Docker enabled
hetzner{02,03}
https://hetzner02.forgejo.org & https://hetzner03.forgejo.org run on EX44 Hetzner hardware.
LXC
Disk partitioning
- First disk
- OS
- a partition configured with DRBD for precious data mounted on /var/lib/lxc
- Second disk
- non precious data such as the LXC containers with runners.
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/
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
ipv4 65.21.67.71 and ipv6 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
.
302 redirects
- On hetzner02
- try.next.forgejo.org redirects to v(latest stable).next.forgejo.org
- dev.next.forgejo.org redirects to v(latest dev).next.forgejo.org
Containers
-
fogejo-code
on hetzner02Dedicated to https://code.forgejo.org
- Docker enabled
- 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
- Docker enabled
/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
- Docker enabled
/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
-
static-pages
on hetzner02See the static pages documenation for more information.
- Unprivileged
-
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.