環境
- HP 8200 Elite (Core i7-2600 / DDR3 16 GB)
- Proxmox VE 7.1-10
- Debian 11 LXC from linuxcontainers.org
- k0s v1.23.3+k0s
PVE 設定
確認必要核心模組,已啟用會輸出 1
cat /proc/sys/net/bridge/bridge-nf-call-iptables
禁用 swap
sysctl vm.swappiness=0
swapoff -a
開啟 IP 轉送
echo 'net.ipv4.ip_forward=1' >> /etc/sysctl.conf
sysctl --system
LXC 設定
- 創建 LXC 並取消勾選
Unprivileged container
- 開啟 PVE shell
- 編輯
/etc/pve/lxc/<ID>.conf
,<ID>
替換成 LXC 編號 - 將以下設定貼在 LXC 設定檔
lxc.apparmor.profile: unconfined
lxc.cgroup.devices.allow: a
lxc.cap.drop:
lxc.mount.auto: "proc:rw sys:rw"
- 存檔並啟動 LXC
修復 Kubernetes /dev/kmsg: no such file or directory
錯誤
在 LXC 裡執行以下指令
cat >/etc/init.d/fix-kmsg <<EOF
#!/bin/sh
ln -s /dev/console /dev/kmsg
EOF
chmod 755 /etc/init.d/fix-kmsg
/etc/init.d/fix-kmsg
接著就可以正常在 LXC 安裝 Kubernetes 了!