Foreword
Raspberry Pi is a widely popular development board, with the further development of things, raspberry pie much as the trend of IoT terminal equipment standards. In support of customers in landing k3s IoT scenario, k3s the deployment of raspberries come in also appeared. This article documents some of the key issues which, relayed written, easy to reference other users.
Hardware: Raspberry Pi 4
k3s version: v1.17.3 + k3s1
operating system:
ubuntu-18.04.4-preinstalled-server-arm64+raspi3.img
After installation using airgap deployed, the core problem is k3s not start, and the following error message log:
The key error message:
level=error msg="Failed to find memory cgroup, you may need to add \"cgroup_memory=1 cgroup_enable=memory\" to your linux cmdline (/boot/cmdline.txt on a Raspberry Pi)"
Investigation records
Log prompted obviously, so we modified /boot/cmdline.txt and restart, but still found the problem after the restart, still have this problem. The nature of the modification is to add kernel parameters, so we check the operating system level:
$ cat /proc/cmdline | grep cgroup_memory
# nothing return
In other words, cmdline changes did not take effect. Therefore, we suspect that this image ubuntu modify cmdline there are other ways:
$ df -hT | grep mmc
/dev/mmcblk0p2 ext4 29G 2.8G 26G 10% /
/dev/mmcblk0p1 vfat 253M 117M 136M 47% /boot/firmware
# 真正的启动分区在/boot/firmware
# 阅读/boot/firmware/README
# 排查后得知,应该修改nobtcmd.txt
After cgroup parameters in /boot/firmware/nobtcmd.txt added after the restart can see cmdline have the desired configuration:
$ cat /proc/cmdline | grep cgroup_memory
coherent_pool=1M ………. cgroup_memory=1 cgroup_enable=memory
Then found k3s still not completed startup, slow log output, some of the factors affecting the suspect system boot process. Entropy investigation, found that the available values are very low, low to clog running generally <1000 program will jam:
$ cat /proc/sys/kernel/random/entropy_avail
522
Many run the program are dependent on random number generation, such as the hash, the encryption and decryption process. entropy apply random number will consume system (entropy), when the entropy low to a certain threshold, the program will run slowly, waiting for random number seed.
In general kernel can collect information from the hardware running noise to supplement the entropy, but the Raspberry Pi hardware capacity is limited, can not quickly generate entropy from the hardware level, so we installed the software simulation algorithms provide added:
$ apt install haveged
$ systemctl enable haveged
$ cat /proc/sys/kernel/random/entropy_avail
2366
After everything is in order, and then view k3s start state, k3s start has been completed.
to sum up
Linux such as Raspberry Pi running in this simple hardware architecture, there are many nuances, it is normally might not established in the knowledge and experience x86 server systems, which led the server software running on Linux and will not be so easy transplanted to the small terminal device. For Raspberry Pi, in addition to the content mentioned in the text, you also need to focus NTP time synchronization, IO performance MicroSD card and so on.