Deploying k0s to alpine

There's a couple of extra things that need to be done before you can run the k0s installer on an alpine host and have it work with a number of standard services:

Start by enabling cgroups v2 and reboot:

#enable cgroups2
echo "rc_cgroup_mode=\"unified\"" >> /etc/rc.conf
reboot

Now start the cgroups service and add it to the startup scripts:

rc-service cgroups start
rc-update add cgroups

Now finally we need to ensure that k0s can access the node's "machine ID":

apk add dbus
rc-service dbus start
rc-update add dbus

That's it! That's the minimum needed to have k0s deployed to an alpine host.

Bonus 1 - Enable eBPF

If you'd like to enable eBPF features (for use with cilium as an example) as well then perform the following:

Edit the /etc/init.d/sysfs file and add the following to the bottom of the mount_misc section:

# setup kernel support for bpf file system
if [ -d /sys/fs/bpf ] && ! mountinfo -q /sys/fs/bpf; then
    if grep -qs bpf /proc/filesystems; then
        ebegin "Mounting eBPF filesystem"
        mount -n -t bpf -o ${sysfs_opts} bpffs /sys/fs/bpf
        eend $?
    fi
fi

Once you've done this you can activate these settings quickly by running /etc/init.d/sysfs restart

Bonus 2 - Enable udev

If you'd like to enable udev features (for example for use with OpenEBS) then complete the following steps:

apk add udev # install udev
# enable udev on startup
rc-update add udev sysinit
rc-update add udev-trigger sysinit
rc-update add udev-settle sysinit

Finally reboot reboot and udev will be enabled!