在 CentOS 上部署 Kubernetes(k8s),通常建议 CentOS 7.9 / CentOS Stream 8/9,下面是最低和推荐配置以及前置要求,适合生产/测试环境参考。
⚠️ 官方建议:Master 至少 2G 内存,Worker 至少 2G
✅ 推荐:
❌ 不推荐:
systemctl stop firewalld
systemctl disable firewalld
setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
swapoff -a
sed -i '/swap/d' /etc/fstab
hostnamectl set-hostname master
cat >> /etc/hosts <<EOF
192.168.1.10 master
192.168.1.11 node1
EOF
modprobe br_netfilter
cat > /etc/sysctl.d/k8s.conf <<EOF
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1
EOF
sysctl --system
Kubernetes 不再支持 docker(1.24+)
✅ 推荐:
yum install -y containerd
systemctl enable --now containerd
需安装:
kubeletkubeadmkubectlyum install -y kubelet kubeadm kubectl
systemctl enable kubelet
kubeadm init \
--apiserver-advertise-address=192.168.1.10 \
--pod-network-cidr=10.244.0.0/16
常用:
kubectl apply -f https://docs.projectcalico.org/manifests/calico.yaml
| 项目 | 要求 |
|---|---|
| 系统 | CentOS 7.9 / Stream 8/9 |
| CPU | ≥2 核 |
| 内存 | ≥2G |
| Swap | 必须关闭 |
| 防火墙 | 关闭 |
| SELinux | 关闭 |
| 容器运行时 | containerd |
| 网络插件 | Calico / Flannel |
如果你愿意,我可以:
你打算 测试还是生产?几台机器?