Deepthink R1
1. Update Alpine Linux and Install Edge Kernel (if needed)
If your Alpine version lacks cgroup2 support (common in older releases), enable the Edge repository for newer kernel packages:
echo "http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories
apk update
apk upgrade2. Install Required Packages
Install tools to manage cgroups:
apk add cgroup-tools3. Enable cgroup2 Kernel Parameters
Edit /boot/extlinux.conf to add kernel flags for cgroup2:
# Append these parameters to the kernel command line:
cgroup_no_v1=all cgroup_enable=memory cgroup_memory=1Example modified entry:
APPEND ... rootfstype=ext4 cgroup_no_v1=all cgroup_enable=memory cgroup_memory=14. Enable the cgroups Service (OpenRC)
Alpine uses OpenRC to manage services. Enable the cgroups service to auto-mount cgroups at boot:
rc-update add cgroups boot # Add to boot runlevel
rc-service cgroups start # Start immediately5. Reboot the System
Apply kernel changes:
reboot6. Verify cgroup2 Mount
After reboot, confirm cgroup2 is mounted:
mount | grep cgroup2
# Expected output:
# cgroup2 on /sys/fs/cgroup type cgroup2 (rw,nosuid,nodev,noexec,relatime)If not mounted, add to /etc/fstab:
echo "none /sys/fs/cgroup cgroup2 defaults 0 0" >> /etc/fstab
mount /sys/fs/cgroup7. Check Available Controllers
Ensure critical controllers (e.g., memory, cpu) are listed:
cat /sys/fs/cgroup/cgroup.controllers8. Configure K3s for cgroupfs Driver
Create /etc/rancher/k3s/config.yaml to force K3s to use cgroupfs (required for non-systemd systems):
kubelet-arg:
- "cgroup-driver=cgroupfs"
containerd:
extra-args:
- "--systemd-cgroup=false"9. Install K3s
Run the installer script:
curl -sfL https://get.k3s.io | sh -10. Verify K3s (OpenRC)
Check K3s status using OpenRC:
rc-service k3s status
# Start manually if needed:
rc-service k3s startTroubleshooting
Missing Controllers
If memory or other controllers are missing:
- Double-check kernel parameters in
/boot/extlinux.conf. - Reboot and verify with
cat /sys/fs/cgroup/cgroup.controllers.
Containerd Configuration
Confirm SystemdCgroup = false in K3s-generated containerd config:
grep "SystemdCgroup" /var/lib/rancher/k3s/agent/etc/containerd/config.toml
# Expected output:
# SystemdCgroup = falsePersistent cgroup Mount
If /sys/fs/cgroup unmounts after reboot:
- Ensure
cgroupsservice is enabled (rc-update show). - Validate
/etc/fstabentry forcgroup2.
Why This Works
- OpenRC Integration: Alpine’s
cgroupsservice handles mounting cgroups at boot. - cgroupfs Driver: K3s uses
cgroupfsinstead ofsystemdfor cgroup management. - Edge Kernel: Provides full cgroup2 support (if required).
This setup ensures K3s works seamlessly with cgroup2 on Alpine Linux. Let me know if you run into issues!