Before the speech

Raspberry PI is a widely popular development board. With the further development of the Internet of Things, raspberry PI will become the standard of IoT terminal devices. When supporting customers to land K3S in IoT scenarios, the deployment issues of K3S on raspberry PI also arise. This paper records some of the key issues, paraphrase written for the convenience of other users.

Hardware: Raspberry PI 4

K3s version: V1.17.3 + K3S1

Operating system:

Ubuntu – 18.04.4 – preinstalled – server – arm64 + raspi3. Img

After the installation is deployed in Airgap mode, the core problem is that K3S cannot be started and the following error information is reported in the log:

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)"
Copy the code

Records of the February

The log message is obvious, so we modify /boot/cmdline.txt and restart, but the problem is still found after the restart, the same problem. The essence of this change is to add kernel parameters, so we check at the operating system level:

$ cat /proc/cmdline | grep cgroup_memory
 # nothing return
Copy the code

That is, the cmdline changes did not take effect. So, we suspect that Ubuntu has another way of modifying cmdline:

$df - hT | grep MMC/dev/mmcblk0p2 corruption 29 10% 26 G/G 2.8 G/dev/mmcblk0p1 vfat 253 m 117 m 136 m 47% / boot/firmwareThe actual boot partition is in /boot/firmware

# read/boot/firmware/README
Nobtcmd.txt should be modified after checking
Copy the code

In/boot/firmware/nobtcmd. TXT cgroup related parameters are added after the restart can see cmdline had expected configuration:

$cat/proc/cmdline | grep cgroup_memory coherent_pool = 1 m... . cgroup_memory=1 cgroup_enable=memoryCopy the code

At this time, it was found that K3S still did not complete the startup and log output was slow. It was suspected that some factors in the system affected the startup process. Entropy is so low that it blocks the program from running. In general, the program will get stuck if it is <1000:

$ cat /proc/sys/kernel/random/entropy_avail
522
Copy the code

Many programs rely on random number generation, such as hashing, encryption and decryption. Applying for a random number consumes the entropy of the system, and when the entropy is low enough to a certain threshold, the program runs slowly, waiting for the seed of a random number.

Generally speaking, kernel can supplement entropy by collecting noise from the hardware running information, but the Raspberry PI’s hardware capabilities are limited and it cannot generate entropy quickly from the hardware level, so we install software to provide simulation algorithms to supplement:

$ apt install haveged 
$ systemctl enable haveged

$ cat /proc/sys/kernel/random/entropy_avail
2366
Copy the code

After all is well, check the startup status of K3S, k3S has been started.

Total knot

Linux running on a simple hardware architecture such as raspberry PI has a lot of nuances that you might not have learned from x86 servers, which makes it difficult for software running on server Linux to be easily ported to smaller devices. For raspberry PI, you’ll need to pay attention to NTP time synchronization, MicroSD card IO performance, and more.