First Steps with CoreOS
From Proxmox to CoreOS #
Just over a year ago now I decided to set up a home server to run a few services for myself. This wouldn’t be anything mission critical, it was largely a learning exercise to keep up to date with the sysadmin side of things as I am doing less of that in my day job.
Initially I installed Proxmox, configured several virtual machines and system containers, and set up Salt to manage them all. It worked great but it felt too complicated for what I was trying to achieve. It would be much simpler to run application containers rather than virtual machines and full-system containers, and although virtual machines give slightly better security through their isolation, podman containers with SELinux would be more than adequate. (Aside: it was the excellent Podman in Action by Daniel Walsh, which I got as a free download from the RedHat Developer Network, that set me off down this road.)
I decided to install Fedora CoreOS on the server. This is an operating system optimized for running container-based workloads and comes with podman and SELinux preinstalled. This post is a summary of my notes from the initial server setup.
Getting started #
I followed the instructions from Installing CoreOS on Bare Metal. The main difference from installing the likes of Ubuntu is that, instead of walking through an interactive installer, you provide an ignition file to configure disk partitions, initial users, systemd services, etc.
Creating a bootable USB #
Download the ISO image:
podman run --security-opt label=disable --rm -v .:/data -w /data \
quay.io/coreos/coreos-installer:release download -s stable -p metal -f iso
Write to USB stick:
sudo dd if=fedora-coreos-39.20231119.3.0-live.x86_64.iso of=/dev/sda bs=8192
Note: you’ll get a newer version if you download this today!
Creating an ignition file #
The ignition file is a JSON file intended for machine consumption. It is generated from a more human-friendly YAML file by running a program called butane to convert it to a JSON ignition configuration.
I started with a fairly minimal butane configuration that specifies the disk partitioning and RAID setup, sets the hostname, configures my preferred keymap, and creates a user called core with authorized keys for SSH login.
---
variant: fcos
version: 1.4.0
boot_device:
mirror:
devices:
- /dev/sda
- /dev/sdb
storage:
disks:
- device: /dev/sda
partitions:
# Override size of root partition on first disk, via the label
# generated for boot_device.mirror
- label: root-1
size_mib: 16384
# Add a new partition filling the remainder of the disk
- label: var-1
- device: /dev/sdb
partitions:
# Similarly for second disk
- label: root-2
size_mib: 16384
- label: var-2
raid:
- name: md-var
level: raid1
devices:
- /dev/disk/by-partlabel/var-1
- /dev/disk/by-partlabel/var-2
filesystems:
- device: /dev/md/md-var
path: /var
label: var
format: xfs
wipe_filesystem: true
with_mount_unit: true
files:
- path: /etc/hostname
mode: 0644
contents:
inline: limiting-factor
- path: /etc/vconsole.conf
mode: 0644
contents:
inline: KEYMAP=dvorak-uk
passwd:
users:
- name: core
ssh_authorized_keys:
- ssh-rsa AAAA...
- ssh-rsa AAAA...
The main thing to note here is that I’ve configured a 16GiB mirrored root filesystem (the documentation says it must be at least 8GiB, which I conservatively doubled), and configured the remaining disk space as a RAID 1 partition. Ideally I would have configured LUKS encryption but the options appeared to be to use TPM2 or Tang and I wanted to avoid the complexity of either.
To turn this butane file into an ignition configuration, I ran:
podman run --rm -i --security-opt label=disable -v ${PWD}:/pwd -w /pwd \
quay.io/coreos/butane:release config.bu > config.ign
Serving the ignition file over HTTP #
The installer wants to load the ignition configuration via HTTP, so in this same directory I ran a simple web server:
python3 -m http.server 3000
I also had to open up the firewall on my workstation to allow access to the web server from the local network:
sudo ufw allow from 192.168.1.0/24 to any port 3000 proto tcp
Running the installer #
After booting from the USB stick I was dropped at a shell prompt, where I ran:
sudo coreos-installer install /dev/sda --ignition-url http://192.168.1.83:3000/config.ign \
--insecure-ignition
The IP address is that of my workstation running the web server. The --insecure-ignition option is required because it is not running over HTTPS.
Once this step has completed, remove the USB stick and reboot to apply the ignition configuration.
After this reboot, you should be able to SSH into the system as the core user.
After the install #
I plan on using ansible to configure the server, and this requires Python to be installed on the system. CoreOS is an atomic, image-based system (filesystems like /usr are mounted read-only), so you have to use rpm-ostree to layer additional packages on top of the base image then reboot into the new filesystem tree:
sudo rpm-ostree install python3
sudo systemctl reboot
This allows for atomic updates and rollbacks to previous versions if something goes wrong. The idea is that most software will be installed in containers so it is rare to need to install packages like this - almost one year on python3 is the only package I have added.
Automatic updates #
The system is configured to apply updates automatically using Zincati. This is an agent that continuously polls a server for updates, downloads and stages them, then reboots the server to apply them.
The updates can be configured to be immediate (reboot to apply the update as soon as it has been staged locally), fleet_lock to orchestrate updates within a cluster, or periodic to specify a time window in which reboots can happen. My home server is configured to apply updates immediately: fine for something that is not mission critical, where the service interruption can be tolerated.
Next steps #
The next step is to start deploying services, which I will cover in a future post.