k8s 安装
master 172.18.32.225 Anolis OS release 8.8
node 172.18.32.226 Anolis OS release 8.8
k8s v1.32.0
配置宿主机
# 将 SELinux 设置为 permissive 模式(相当于将其禁用)
sudo setenforce 0
sudo sed -i 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config
# 关闭swap
swapoff -a
# 开启转发
echo 1 > /proc/sys/net/ipv4/ip_forward
#### 加载 br_netfilter
modprobe br_netfilter
lsmod | grep br_netfilter
containerd
下载
cd /opt/soft/containerd/
wget https://github.com/containerd/containerd/releases/download/v1.7.25/containerd-1.7.25-linux-amd64.tar.gz
配置
生成默认配置
mkdir -p /etc/containerd
./containerd config default | sudo tee /etc/containerd/config.toml
修改镜像源
vi tee /etc/containerd/config.toml
, 在 [plugins."io.containerd.grpc.v1.cri".registry.mirrors]
后添加
# [plugins."io.containerd.grpc.v1.cri".registry.mirrors]
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."docker.io"]
endpoint=["https://dockerpull.cn"]
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."registry.k8s.io"]
endpoint=["https://dockerpull.cn"]
创建服务
cat <<EOF | tee /etc/systemd/system/containerd.service
[Unit]
Description=containerd container runtime
Documentation=https://containerd.io
After=network.target
[Service]
ExecStart=/opt/soft/containerd/containerd
Restart=always
RestartSec=5
Delegate=yes
KillMode=process
LimitNOFILE=1048576
LimitNPROC=1048576
LimitCORE=infinity
[Install]
WantedBy=multi-user.target
EOF
启动服务
systemctl daemon-reload
systemctl start containerd
systemctl enable containerd
安装 kubelet kubeadm kubectl
# 此操作会覆盖 /etc/yum.repos.d/kubernetes.repo 中现存的所有配置
cat <<EOF | sudo tee /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://pkgs.k8s.io/core:/stable:/v1.32/rpm/
enabled=1
gpgcheck=1
gpgkey=https://pkgs.k8s.io/core:/stable:/v1.32/rpm/repodata/repomd.xml.key
exclude=kubelet kubeadm kubectl cri-tools kubernetes-cni
EOF
# 安装 kubelet、kubeadm 和 kubectl,并启用 kubelet 以确保它在启动时自动启动:
sudo yum install -y kubelet kubeadm kubectl --disableexcludes=kubernetes
sudo systemctl enable --now kubelet
启动集群
# master
kubeadm init --pod-network-cidr=192.168.100.0/24
执行成功后会生成添加节点的命令,到 node 节点上执行该命令添加 node.
kubeadm join 172.18.32.225:6443 ...
cni
配置 cni
wget https://raw.githubusercontent.com/flannel-io/flannel/master/Documentation/kube-flannel.yml
vi kube-flannel.yml
找到 net-conf.json, 修改 Network 字段为 192.168.0.0/16
启动 cni
kubectl apply -f kube-flannel.yml
标签:containerd,etc,registry,io,k8s,安装,flannel
From: https://www.cnblogs.com/aloe-n/p/18675537