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:

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.

As a bonus if you'd like to enable eBPF features 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

If you were deploying k0s with cilium instead of the default kube-router/kube-proxy combo you'll want to add the following after the mount command above:

mount --make-shared /sys/fs/bpf
mount --make-shared /run/cilium/cgroupv2

So the full block will look like:

# 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
        mount --make-shared /sys/fs/bpf
        mount --make-shared /run/cilium/cgroupv2
        eend $?
    fi
fi

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