Closed6

Raspberry Pi 4 + Ubuntu 21.10 + Kubernetes 1.24

Kazuki Suda (@superbrothers)Kazuki Suda (@superbrothers)

Raspberry Pi 4 + Ubuntu 21.10 + Kubernetes 1.23 の環境を 1.24 に更新する。Kubernetes のアップグレードに合わせて apt パッケージを最新に更新する。

Kazuki Suda (@superbrothers)Kazuki Suda (@superbrothers)

Ubuntu 21.10 は cgroups v2 がデフォルトで有効になっているが、Kubernetes での cgroups v2 のサポートは十分にテストされていないので、無効化しておく。1.23 を cgroups v2 で運用しちゃっていて特に問題なかったけど。

通常は /etc/default/grubGRUB_CMDLINE_LINUX に次の設定を追加すればよいが、Raspberry Pi 向けの Ubuntu では /boot/firmware/cmdline.txt に追加する。

systemd.unified_cgroup_hierarchy=0 systemd.legacy_systemd_cgroup_controller=1

systemd.legacy_systemd_cgroup_controller=1 も付けて完全に cgroups v2 を無効化しておく。

Kazuki Suda (@superbrothers)Kazuki Suda (@superbrothers)

自分は kubeadm upgrade は使わずに kubeadm reset してから kubeadm join するようにしているので、次の playbook を実行してリセットしてから apt upgrade、再起動して、kubeadm join という流れで更新している。

- hosts: all
  become: true
  tasks:
  - name: kubectl drain node
    command: kubectl drain "{{ ansible_facts['hostname'] }}" --ignore-daemonsets --delete-emptydir-data --kubeconfig /etc/kubernetes/admin.conf
    ignore_errors: true

  - name: kubectl delete node
    command: kubectl delete node "{{ ansible_facts['hostname'] }}"
    ignore_errors: true

  - name: kubeadm reset
    command: kubeadm reset --force
    ignore_errors: true

  - name: uninstall kubernetes packages
    apt:
      name:
      - kubelet
      - kubeadm
      - kubectl
      autoremove: true
      state: absent

  - name: remove files and directories
    file:
      path: "{{ item }}"
      state: absent
    with_items:
    - /usr/local/bin/nerdctl
    - /usr/local/bin/containerd
    - /opt/cni
    - /etc/cni
    - /var/lib/cni
Kazuki Suda (@superbrothers)Kazuki Suda (@superbrothers)

よくなるやつ。

$ sudo apt upgrade
...
The following packages have unmet dependencies:
 pi-bluetooth : Depends: bluez-firmware but it is not installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

$ sudo apt install bluez-firmware
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following package was automatically installed and is no longer required:
  libfwupdplugin1
Use 'sudo apt autoremove' to remove it.
The following NEW packages will be installed:
  bluez-firmware
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
62 not fully installed or removed.
Need to get 0 B/175 kB of archives.
After this operation, 332 kB of additional disk space will be used.
Setting up systemd-timesyncd (248.3-1ubuntu8.6) ...
Setting up systemd (248.3-1ubuntu8.6) ...
(Reading database ... 121327 files and directories currently installed.)
Preparing to unpack .../bluez-firmware_1.2-4+rpt8_all.deb ...
Unpacking bluez-firmware (1.2-4+rpt8) ...
dpkg: error processing archive /var/cache/apt/archives/bluez-firmware_1.2-4+rpt8_all.deb (--unpack):
 trying to overwrite '/lib/firmware/brcm/BCM43430A1.hcd', which is also in package linux-firmware-raspi2 6-0ubuntu0~21.10.1
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Errors were encountered while processing:
 /var/cache/apt/archives/bluez-firmware_1.2-4+rpt8_all.deb
needrestart is being skipped since dpkg has failed
E: Sub-process /usr/bin/dpkg returned an error code (1)
Kazuki Suda (@superbrothers)Kazuki Suda (@superbrothers)
 trying to overwrite '/lib/firmware/brcm/BCM43430A1.hcd', which is also in package linux-firmware-raspi2 6-0ubuntu0~21.10.1

とのことなので、overwrite しちゃう。

$ sudo dpkg -i --force-overwrite /var/cache/apt/archives/bluez-firmware_1.2-4+rpt8_all.deb
(Reading database ... 121327 files and directories currently installed.)
Preparing to unpack .../bluez-firmware_1.2-4+rpt8_all.deb ...
Unpacking bluez-firmware (1.2-4+rpt8) ...
dpkg: warning: overriding problem because --force enabled:
dpkg: warning: trying to overwrite '/lib/firmware/brcm/BCM43430A1.hcd', which is also in package linux-firmware-raspi2 6-0ubuntu0~21.10.1
dpkg: warning: overriding problem because --force enabled:
dpkg: warning: trying to overwrite '/lib/firmware/brcm/BCM43430B0.hcd', which is also in package linux-firmware-raspi2 6-0ubuntu0~21.10.1
dpkg: warning: overriding problem because --force enabled:
dpkg: warning: trying to overwrite '/lib/firmware/brcm/BCM4345C0.hcd', which is also in package linux-firmware-raspi2 6-0ubuntu0~21.10.1
dpkg: warning: overriding problem because --force enabled:
dpkg: warning: trying to overwrite '/lib/firmware/brcm/BCM4345C5.hcd', which is also in package linux-firmware-raspi2 6-0ubuntu0~21.10.1
Setting up bluez-firmware (1.2-4+rpt8) ...
Kazuki Suda (@superbrothers)Kazuki Suda (@superbrothers)
Setting up raspberrypi-kernel (1:1.20220331-1) ...
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 5.15.32+ /boot/kernel.img
run-parts: executing /etc/kernel/postinst.d/unattended-upgrades 5.15.32+ /boot/kernel.img
run-parts: executing /etc/kernel/postinst.d/update-notifier 5.15.32+ /boot/kernel.img
run-parts: executing /etc/kernel/postinst.d/xx-update-initrd-links 5.15.32+ /boot/kernel.img
run-parts: executing /etc/kernel/postinst.d/zz-flash-kernel 5.15.32+ /boot/kernel.img
/etc/kernel/postinst.d/zz-flash-kernel:
Using DTB: bcm2711-rpi-4-b.dtb
Couldn't find DTB bcm2711-rpi-4-b.dtb on the following paths: /etc/flash-kernel/dtbs /usr/lib/linux-image-5.15.32+ /lib/firmware/5.15.32+/device-tree/
Installing  into /boot/dtbs/5.15.32+/./bcm2711-rpi-4-b.dtb
cp: cannot stat '': No such file or directory
run-parts: /etc/kernel/postinst.d/zz-flash-kernel exited with return code 1
dpkg: error processing package raspberrypi-kernel (--configure):
 installed raspberrypi-kernel package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
 raspberrypi-kernel
needrestart is being skipped since dpkg has failed
E: Sub-process /usr/bin/dpkg returned an error code (1)

/lib/firmware/5.15.32+/device-tree/bcm2711-rpi-4-b.dtb が存在しないことが問題のよう。細かく何が悪いのかはわからないけど、とにかくファイルを置いてやって回避する。

sudo cp -r /lib/firmware/5.13.0-1031-raspi /lib/firmware/5.15.32+
sudo cp -r /lib/firmware/5.13.0-1031-raspi /lib/firmware/5.15.32-v7+
sudo cp -r /lib/firmware/5.13.0-1031-raspi /lib/firmware/5.15.32-v7l+
sudo cp -r /lib/firmware/5.13.0-1031-raspi /lib/firmware/5.15.32-v8+
このスクラップは2022/07/28にクローズされました