目录
基于Calico+Containerd的Kubernetes v1.28.2生产环境部署方案
2.2 转发 IPv4 并让 iptables 看到桥接流量
2.2 确认 br_netfilter 和 overlay 模块被加载:
5.1 安装 kubeadm、kubelet、kubectl(所有节点执行)
7.2修改calico.yaml文件中所有docker.io开头的镜像
7.3修改定义pod网络CALICO_IPV4POOL_CIDR的值
以下是基于Calico+Containerd的Kubernetes v1.28.2生产环境部署方案,
基于Calico+Containerd的Kubernetes v1.28.2生产环境部署方案
一、环境准备
1.1 规划
角色 |
主机名 |
IP地址 |
Master |
master |
192.168.203.131 |
Node1 |
node |
192.168.203.132 |
1.2 先更新系统
apt update && \
apt upgrade -y
1.3 配置Hosts
cat <<EOF | sudo tee -a /etc/hosts
192.168.203.131 master
192.168.203.132 node
EOF
二、系统加固与优化
操作:所有节点
2.1 关闭防火墙、SELinux、Swap
systemctl disable --now ufw
swapoff -a
sed -i '/swap/s/^\(.*\)$/#\1/g' /etc/fstab
2.2 转发 IPv4 并让 iptables 看到桥接流量
cat <<EOF | tee /etc/modules-load.d/k8s.conf
overlay
br_netfilter
EOF
modprobe overlay
modprobe br_netfilter
# 设置所需的 sysctl 参数,参数在重新启动后保持不变
cat <<EOF | 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 参数而不重新启动
sysctl --system
2.2 确认 br_netfilter 和 overlay 模块被加载:
lsmod | grep br_netfilter
lsmod | grep overlay
8、通过运行以下指令确认 net.bridge.bridge-nf-call-iptables、net.bridge.bridge-nf-call-ip6tables 和 net.ipv4.ip_forward 系统变量在你的 sysctl 配置中被设置为 1
sysctl net.bridge.bridge-nf-call-iptables net.bridge.bridge-nf-call-ip6tables net.ipv4.ip_forward
三、Containerd安装
操作:所有节点
4.1 安装containerd
curl -# -O https://mirrors.aliyun.com/docker-ce/linux/ubuntu/dists/jammy/pool/stable/amd64/containerd.io_1.6.26-1_amd64.deb
dpkg -i containerd.io_1.6.26-1_amd64.deb
#导出默认配置
containerd config default > /etc/containerd/config.toml
#修改containerd使用SystemdCgroup
SystemdCgroup = true
#配置containerd使用国内mirror站点上的pause镜像及指定版本
sandbox_image = "registry.aliyuncs.com/google_containers/pause:3.9"
#启动containerd服务
systemctl enable containerd --now
containerd -v