[KVM] Fedora CoreOS Simple Local Deployment #0
May 31, 2024•410 words
Introduction
Fedora CoreOS is an awesome Linux operating system. Fedora CoreOS is an immutable OS excluding the /var
and /etc
paths, both of which can be modified. While /home
exists, it's a symlink that point to /var/home
. To configure Fedora CoreOS the way we want it, we can use the ignition Config File.
Pre-requisites
To follow along with this walk through you need
Ignition Config
- The Ignition Config can be used to provision a Fedora CoreOS system.
- It is run only once at boot
- It can be used to configure things like storage and filesystems, systemd units, and users. This means that we can
- run podman systemd units on startup to run containers. This alone gives us almost endless possibilities!
- we can setup files and folders on the system. For example, our application can be configured through a config file
config.yaml
which needs to be placed in/etc/<app>/config.yaml
, we can defiine this in the ignition config.
Learn more about the ignition config here
Setup
For a quick setup to see the workflow of the deployment, let's create a directory and write a butane config to acheive a simple task.
Project Setup
first let's create a directory using mkdir -p /home/Documents/fcos
Butane Config
we can now create a butane file at /home/Documents/fcos/config.bu
. For now, let's copy the sample config file provided at butane config
variant: fcos
version: 1.5.0
passwd:
users:
- name: core
ssh_authorized_keys:
- ssh-rsa <your-public-ssh-key>
This config file creates a user core
and sets the public key for who is allowed to login as this user using ssh.
Simple deployment
Steps needed for a simple deployment include
- creating a
butane
config file (a more human readable ignition config) - convert the butane file into an ignition config file
- launch a Fedora CoreOS system with the defined config.
we can create a short bash script to automatically convert the butane.bu
file to an ignition config file and then run the system.
#!/bin/bash
# path to butane config
BUTANE_CONFIG="/home/Documents/fcos/config.bu"
podman run --interactive --rm quay.io/coreos/butane:release \
--pretty --strict < ${BUTANE_CONFIG} > /home/Documents/fcos/transpiled_config.ign
IGNITION_CONFIG="/home/Documents/fcos/transpiled_config.ign"
IMAGE="path/to/qcow2/image.qcow2"
# for x86/aarch64:
IGNITION_DEVICE_ARG="-fw_cfg name=opt/com.coreos/config,file=${IGNITION_CONFIG}"
qemu-kvm -m 2048 -cpu host -nographic -snapshot \
-drive if=virtio,file=${IMAGE} ${IGNITION_DEVICE_ARG} \
-nic user,model=virtio,hostfwd=tcp::2222-:22
save the file to /home/Documents/fcos/run.sh
. run the script to run Fedora CoreOS. we can then ssh into the instance using the command ssh core@localhost -p 2222
.