hostnamectl set-hostname k8s-master
hostnamectl set-hostname k8s-node-1
hostnamectl set-hostname k8s-node-2
vi /etc/hosts
172.24.214.110 k8s-master
172.24.214.108 k8s-node-1
172.24.214.109 k8s-node-2
yum install update
yum install lrzsz
yum install -y conntrack ipvsadm ipset jq sysstat curl iptables libseccomp
wget -O docker.sh https://files.rundreams.net/sh/docker.sh && sh docker.sh
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://j16wttpi.mirror.aliyuncs.com"]
}
EOF
wget https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo -O /etc/yum.repos.d/docker-ce.repo
yum install -y docker-ce
systemctl start docker
systemctl enable docker
docker info
wget -O k8s-init.sh https://files.rundreams.net/sh/k8s-init.sh && sh k8s-init.sh
systemctl stop firewalld && systemctl disable firewalld
setenforce 0
sed -i 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config
swapoff -a
sed -i '/swap/s/^\(.*\)$/#\1/g' /etc/fstab
iptables -F && iptables -X && iptables -F -t nat && iptables -X -t nat && iptables -P FORWARD ACCEPT
cat <<EOF > /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF
sysctl --system
链接:https://pan.baidu.com/s/1zBjp74MDV8Kkrnp2ZZbeNQ?pwd=8dpk
提取码:8dpk
链接:https://caiyun.139.com/m/i?1F5C35BxQfMvl
提取码:De7b
tar -xf cri-dockerd-0.2.6.amd64.tgz
cp cri-dockerd/cri-dockerd /usr/bin/
chmod +x /usr/bin/cri-dockerd
cat <<"EOF" > /usr/lib/systemd/system/cri-docker.service
[Unit]
Description=CRI Interface for Docker Application Container Engine
Documentation=https://docs.mirantis.com
After=network-online.target firewalld.service docker.service
Wants=network-online.target
Requires=cri-docker.socket
[Service]
Type=notify
ExecStart=/usr/bin/cri-dockerd --network-plugin=cni --pod-infra-container-image=registry.aliyuncs.com/google_containers/pause:3.7
ExecReload=/bin/kill -s HUP $MAINPID
TimeoutSec=0
RestartSec=2
Restart=always
StartLimitBurst=3
StartLimitInterval=60s
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
TasksMax=infinity
Delegate=yes
KillMode=process
[Install]
WantedBy=multi-user.target
EOF
cat <<"EOF" > /usr/lib/systemd/system/cri-docker.socket
[Unit]
Description=CRI Docker Socket for the API
PartOf=cri-docker.service
[Socket]
ListenStream=%t/cri-dockerd.sock
SocketMode=0660
SocketUser=root
SocketGroup=docker
[Install]
WantedBy=sockets.target
EOF
systemctl daemon-reload
systemctl enable cri-docker --now
systemctl is-active cri-docker
cat > /etc/yum.repos.d/kubernetes.repo << EOF
[kubernetes]
name=Kubernetes
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
enabled=1
gpgcheck=0
repo_gpgcheck=0
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
EOF
yum install -y kubelet-1.25.0 kubeadm-1.25.0 kubectl-1.25.0
kubeadm version
systemctl enable kubelet
cat <<EOF > /etc/sysconfig/kubelet
KUBELET_EXTRA_ARGS="--cgroup-driver=systemd"
EOF
cat <<EOF > /etc/docker/daemon.json
{
"registry-mirrors": ["https://j16wttpi.mirror.aliyuncs.com"],
"exec-opts": ["native.cgroupdriver=systemd"]
}
EOF
systemctl daemon-reload
systemctl restart docker
kubeadm init \
--apiserver-advertise-address=172.24.214.110 \
--image-repository registry.aliyuncs.com/google_containers \
--kubernetes-version v1.25.0 \
--service-cidr=10.10.0.0/12 \
--pod-network-cidr=172.17.0.0/16 \
--cri-socket /var/run/cri-dockerd.sock \
--ignore-preflight-errors=all
kubeadm join 172.24.214.110:6443 --token 5efiso.2zibi97nx4cunivt \
--discovery-token-ca-cert-hash sha256:158fb29cb08d54e58d76239292eed553c25c54fb307424bee8d5776690827303 \
--cri-socket /var/run/cri-dockerd.sock
wget https://docs.projectcalico.org/manifests/calico.yaml --no-check-certificate
链接:https://pan.baidu.com/s/1KATNHOZdtZ0169NLfa2JDQ?pwd=nhp6
提取码:nhp6
calico.yaml https://www.aliyundrive.com/s/geVBb4b4t2A
链接: https://caiyun.139.com/m/i?1F5C2RFMpI4zl
提取码:Fm1S
链接:https://pan.baidu.com/s/1nxQAJX21-dbaZRkv4pbvWg?pwd=6w6j
提取码:6w6j
链接:https://caiyun.139.com/m/i?1F5C2lG1dGd66
提取码:Odq8
docker load -i calico~cni~v3.24.3.tar.gz
docker load -i calico~kube~controllers~v3.24.3.tar.gz
docker load -i calico~node~v3.24.3.tar.gz
docker images | grep calico
查看是否成功kubectl apply -f calico.yaml
kubectl get node -o wide
https://blog.csdn.net/qq_41822345/article/details/126679925
https://blog.csdn.net/xiaohuixing16134/article/details/102784269
https://blog.csdn.net/bilibilidicks/article/details/125825282
https://blog.csdn.net/zl8751/article/details/126308198
https://blog.csdn.net/weibo1230123/article/details/121732361
https://blog.csdn.net/u010800804/article/details/124524688
Unfortunately, an error has occurred:
timed out waiting for the condition
This error is likely caused by:
- The kubelet is not running
- The kubelet is unhealthy due to a misconfiguration of the node in some way (required cgroups disabled)
If you are on a systemd-powered system, you can try to troubleshoot the error with the following commands:
- ‘systemctl status kubelet’
- ‘journalctl -xeu kubelet’
Additionally, a control plane component may have crashed or exited when started by the container runtime.
To troubleshoot, list all containers using your preferred container runtimes CLI.
Here is one example how you may list all running Kubernetes containers by using crictl:
- ‘crictl --runtime-endpoint unix:///var/run/cri-dockerd.sock ps -a | grep kube | grep -v pause’
Once you have found the failing container, you can inspect its logs with:
- ‘crictl --runtime-endpoint unix:///var/run/cri-dockerd.sock logs CONTAINERID’
error execution phase wait-control-plane: couldn’t initialize a Kubernetes cluster
To see the stack trace of this error execute with --v=5 or higher
Found multiple CRI endpoints on the host. Please define which one do you wish to use by setting the ‘criSocket’ field in the kubeadm configuration file: unix:///var/run/containerd/containerd.sock, unix:///var/run/cri-dockerd.sock
To see the stack trace of this error execute with --v=5 or higher