Prerequisites
- Minimal Installed Debian 12 /11
- 2 CPU / vCPU
- 2 GB RAM
- 20 GB free disk space
- Sudo User with Admin rights
- Stable Internet Connectivity
- Ensure that each node can communicate with the others via a reliable network connection.
1. 設定hostname和hosts檔案
sudo hostnamectl set-hostname "master" // Run on master node
sudo hostnamectl set-hostname "node1" // Run on 1st worker node
sudo hostnamectl set-hostname "ndoe2" // Run on 2nd worker node
/etc/hosts 配置
10.0.8.2 master
10.0.0.6 node1
10.0.8.15 node2
2. 關閉所有節點的swap
目的:1. 平滑執行 2. 讓記憶體洩漏的容器快速死亡
sudo swapoff -a
sudo sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab
debian 非root下可能沒有設定/usr/sbin 的環境變數,導致無法執行一些命令,設定下即可。
3. 新增防火牆規則
4. 安裝Container
安裝前所有節點設定核心引數
$ cat <<EOF | sudo tee /etc/modules-load.d/containerd.conf
overlay
br_netfilter
EOF
$ sudo modprobe overlay
$ sudo modprobe br_netfilter
$ cat <<EOF | sudo tee /etc/sysctl.d/99-kubernetes-k8s.conf
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1
net.bridge.bridge-nf-call-ip6tables = 1
EOF
執行 sudo sysctl --system
使得引數修改生效
安裝Container
sudo apt update
sudo apt -y install containerd
在所有節點生成匯入預設配置
containerd config default | sudo tee /etc/containerd/config.toml >/dev/null 2>&1
使用SystemdCgroup配置,將 ‘SystemdCgroup = false’ 修改為 ‘SystemdCgroup = true‘
sudo vi /etc/containerd/config.toml
重啟服務使配置生效
sudo systemctl restart containerd
sudo systemctl enable containerd
- 新增kubernetes源
echo "deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.28/deb/ /" | sudo tee /etc/apt/sources.list.d/kubernetes.list
` curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.28/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg`