1、关闭swap: vi /etc/fstab 注释掉swap那行;
2、关闭防火墙和selinux:systemctl stop firewalld && setenforce 0
3、配置国内yum源:
sed -e 's|^mirrorlist=|#mirrorlist=|g' \ -e 's|^#baseurl= http://dl.rockylinux.org/$contentdir|baseurl=https://mi rrors.aliyun.com/rockylinux|g' \ -i /etc/yum.repos.d/rocky*.repo
4、开启Ipv4:
cat > /etc/modules-load.d/k8s.conf <<EOF
overlay
br_netfilter
EOF
sudo modprobe overlay
sudo modprobe br_netfilter
5、安装docker、yum源:
yum install -y yum-utils containered
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/cen
tos/docker-ce.repo
配置k8s源和安装k8s : cat <<EOF | tee /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://mirrors.aliyun.com/kubernetes-new/core/stable/v1.30/rpm/
enabled=1
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/kubernetes-new/core/stable/v1.30/rpm/repo
data/repomd.xml.key
EOF
yum install kubelet-1.30.0 kubeadm-1.30.0 kubectl-1.30.0 -y
# 检查版本是否正确
kubeadm version
systemctl enable kubelet --now
初始化K8s集群:
kubeadm init \
--apiserver-advertise-address="192.168.222.31" \
--control-plane-endpoint="vip.net" \
--image-repository registry.aliyuncs.com/google_containers \
--kubernetes-version v1.30.0 \
--service-cidr=10.96.0.0/16 \
--pod-network-cidr=10.10.0.0/16 \
--cri-socket=unix:///var/run/cri-dockerd.sock
最后再执行:
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
新的节点Containerd如何纳⼊到集群中
● 1、安装Containerd
● 2、安装nerdctl、buildkitd
● 3、启动containerd、buildkit、kubelet
● 4、安装kubelet、kubectl、kubeadm
● 5、执⾏kubeadm join加⼊集群;
6、kubeadm token create --print-join-command;
安装网络插件: wget https://github.com/flannel-io/flannel/releases/down
load/v0.25.1/kube-flannel.yml
集群信息如下: