This repository contains the files necessary to automatically build a containerized version of Fedora with k3s preinstalled. The goal of this repository is to generate a stable base OS to deploy containers on. This is a personal experiment. No warranty or support is provided.
Generating an ISO using this container will opt you in for automatic updates from this repository. The generated ISO will install automatically to the first internal device found.
First, pull the image locally:
sudo podman pull ghcr.io/pixpmusic/fedora-bootc-k3s-controller:latestThen, build an ISO (or VM image):
sudo podman run \
--rm \
-it \
--privileged \
--pull=newer \
--security-opt label=type:unconfined_t \
-v ./output:/output \
-v /var/lib/containers/storage:/var/lib/containers/storage \
quay.io/centos-bootc/bootc-image-builder:latest \
--type anaconda-iso \
--rootfs btrfs \
--use-librepo=True \
ghcr.io/pixpmusic/fedora-bootc-k3s-controller:latestYou can optionlly supply a /config.toml to add a user or supply advanced Anaconda customization, or you can build an image for a VM or cloud platform by adjusting the --type.
For more information, see bootc-image-builder docs, however, I've added cloud-init to allow me to use cloud-config to configure my nodes on first boot.
There are example cloud-config.yaml files in the repository. These can be used to set the hostname for each system and configure your pre-shared key and otherwise configure each individual node.
Cloud-Init can be injected via some hypervisors, as well as by hosting the configuration via the network, but it can also be used via generating an ISO image or USB key.
First, create a temporary directory:
mkdir temp_isoCopy the cloud-init.yaml to temp_iso/user-data:
cp ./cloud-config-controller1.yaml ./temp_iso/user-dataMake an empty meta-data file:
touch ./temp_iso/meta-dataGenerate the ISO image from these files:
cd ./temp_iso/
genisoimage -output controller1.iso -volid cidata -joliet -rock user-data meta-dataEnsure this ISO is mounted to the VM or burnt to a CD or DVD in the disk drive of the machine you're configuring during the first boot after installation.
Format your USB drive with a label, cidata, ensuring you replace /dev/sdb1 with the device entry for your USB key:
This will remove all data from the target device. Proceed with caution.
sudo mkfs.vfat -n 'cidata' /dev/sdb1Remove and reinsert the USB drive. If it is not mounted automatically, mount it manually:
sudo mkdir -p /mnt/cidata_usb
sudo mount /dev/sdb1 /mnt/cidata_usbCopy the cloud-init.yaml as user-data and create an empty meta-data file:
sudo cp ./cloud-config-controller1.yaml /mnt/cidata_usb/user-data
sudo touch /mnt/cidata_usb/meta-dataUnmount the disk:
sudo umount /dev/sdb1Ensure this USB is mounted to the VM or inserted in the machine you're configuring during the first boot after installation.
Pull the repo locally and cd into the directory:
git clone git@github.com:PixPMusic/fedora-bootc-k3s-controller
cd fedora-bootc-k3s-controllerEnsure you build rootfully, and tag your image:
sudo podman build -t k3s-controller .Now, generate an ISO:
sudo podman run \
--rm \
-it \
--privileged \
--pull=newer \
--security-opt label=type:unconfined_t \
-v ./output:/output \
-v /var/lib/containers/storage:/var/lib/containers/storage \
quay.io/centos-bootc/bootc-image-builder:latest \
--type anaconda-iso \
--rootfs btrfs \
--use-librepo=True \
localhost/k3s-controller:latest