树莓派安装 kubernetes v1.27.2

Ubuntu 22.04.2 LTS
ARM64位系统
kubernetes v1.27.2

以前写过一篇安装教程 https://blog.haohtml.com/archives/30924 ,当时安装的版本是 < v1.24.0 版本,由于k8s 从 v1.24.0 版本开始,弃用了 Dockershim 因此没有办法继续使用 Docker Engine 作为运行时,因此如果还想继续使用旧的运行时的话,则需要安装一个 cri-docker 的软件, 本文主要是介绍(版本 >=v1.24.0 )继续使用 Docker Engine 的安装方法,这里以最新版本 v1.27.1 为例。

安装环境初始化

以下内容来自:https://kubernetes.io/zh-cn/docs/setup/production-environment/container-runtimes/

执行下述指令:

cat <<EOF | sudo tee /etc/modules-load.d/k8s.conf
overlay
br_netfilter
EOF

sudo modprobe overlay
sudo modprobe br_netfilter

# 设置所需的 sysctl 参数,参数在重新启动后保持不变
cat <<EOF | sudo tee /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-iptables  = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.ipv4.ip_forward                 = 1
EOF

# 应用 sysctl 参数而不重新启动
sudo sysctl --system

通过运行以下指令确认 br_netfilteroverlay 模块被加载:

lsmod | grep br_netfilter
lsmod | grep overlay

通过运行以下指令确认 net.bridge.bridge-nf-call-iptablesnet.bridge.bridge-nf-call-ip6tablesnet.ipv4.ip_forward 系统变量在你的 sysctl 配置中被设置为 1:

sysctl net.bridge.bridge-nf-call-iptables net.bridge.bridge-nf-call-ip6tables net.ipv4.ip_forward

上面添加的两个模块只有在 containerd 运行时才会用到(如果已安装过 docker 的话,则将自动安装此服务)。可以通过命令 systemctl cat containerd.service 查看对模块的引用关系

[Unit]
Description=containerd container runtime
Documentation=https://containerd.io
After=network.target local-fs.target

[Service]
ExecStartPre=-/sbin/modprobe overlay
ExecStart=/usr/bin/containerd

Type=notify
Delegate=yes
KillMode=process
Restart=always
RestartSec=5
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNPROC=infinity
LimitCORE=infinity
LimitNOFILE=infinity
# Comment TasksMax if your systemd version does not supports it.
# Only systemd 226 and above support this version.
TasksMax=infinity
OOMScoreAdjust=-999

[Install]
WantedBy=multi-user.target

不过这里安装了这两个模块也没有任何影响。

安装 Docker

参考官方文档 https://docs.docker.com/engine/install/ubuntu/ 或aliyun 文档 https://developer.aliyun.com/mirror/docker-ce

Continue reading