![基于docker和cri-dockerd部署kubernetes v1.25.3](http://img.zhejianglong.com/231019/131TB5P-0.png)
文章插图
#如果初始化报如下错误: Error getting node" err="node \"k8s-master01\" not found ? #1、在cri-docker.service文件指定下pause版本: [root@k8s-master01 ~]# vim /usr/lib/systemd/system/cri-docker.service ExecStart=/usr/bin/cri-dockerd --pod-infra-container-image=registry.aliyuncs.com/google_containers/pause:3.8 --container-runtime-endpoint fd:// --network-plugin=cni --cni-bin-dir=/opt/cni/bin --cni-cache-dir=/var/lib/cni/cache --cni-conf-dir=/etc/cni/net.d #2、重启服务: systemctl daemon-reload systemctl restart cri-docker.service ? #3、重置集群: kubeadm reset --cri-socket unix:///run/cri-dockerd.sock && rm -rf /etc/kubernetes/ /var/lib/kubelet /var/lib/dockershim /var/run/kubernetes /var/lib/cni /etc/cni/net.d
7、部署网络插件 #所有节点执行: #下载链接: https://github.com/flannel-io/flannel/releases ? [root@k8s-master01 ~]# cp flanneld-amd64 /opt/bin/flanneld [root@k8s-master01 ~]# chmod +x /opt/bin/flanneld [root@k8s-master01 ~]# ll /opt/bin/flanneld -rwxr-xr-x 1 root root 39358256 11月 4 22:46 /opt/bin/flanneld* ? ?
#第一个主节点执行: #部署kube-flannel [root@k8s-master01 ~]# kubectl apply -f https://raw.githubusercontent.com/flannel-io/flannel/master/Documentation/kube-flannel.yml namespace/kube-flannel created clusterrole.rbac.authorization.k8s.io/flannel created clusterrolebinding.rbac.authorization.k8s.io/flannel created serviceaccount/flannel created configmap/kube-flannel-cfg created daemonset.apps/kube-flannel-ds created ? #确认Pod的状态为“Running” [root@k8s-master01 ~]# kubectl get pods -n kube-flannel NAME READY STATUS RESTARTS AGE kube-flannel-ds-9bkgl 1/1 Running 0 50s ? #此时,k8s-master01已经就绪 [root@k8s-master01 ~]# kubectl get nodes NAME STATUS ROLES AGE VERSION k8s-master01 Ready control-plane 20m v1.25.3
8、添加其他节点到集群中【基于docker和cri-dockerd部署kubernetes v1.25.3】 #k8s-master02和k8s-master03执行: #k8s-master02和k8s-master03加入集群 [root@k8s-master02 ~]# kubeadm join kubeapi.wang.org:6443 --token s800nl.dtylo6tpgghpre7p --discovery-token-ca-cert-hash sha256:a13ee9d0212edbd255fe0c5929186725b217a650f0b04ba75c6a1d6e67576aea --control-plane --certificate-key 185090182962d3e322ff37a902734bfdd769e8e6e82d796bc882d0b1967c9886 --cri-socket unix:///run/cri-dockerd.sock ? #注意,命令需要加上--cri-socket unix:///run/cri-dockerd.sock
#k8s-node01、k8s-node02、k8s-node03执行 #node节点加入集群 ? [root@k8s-node01 ~]# kubeadm join kubeapi.wang.org:6443 --token s800nl.dtylo6tpgghpre7p --discovery-token-ca-cert-hash sha256:a13ee9d0212edbd255fe0c5929186725b217a650f0b04ba75c6a1d6e67576aea --cri-socket unix:///run/cri-dockerd.sock ? #注意,命令需要加上--cri-socket unix:///run/cri-dockerd.sock
#第一节点验证节点添加结果 ? [root@k8s-master01 ~]#kubectl get nodes NAME STATUS ROLES AGE VERSION k8s-master01 Ready control-plane 25m v1.25.3 k8s-master02 Ready control-plane 10m v1.25.3 k8s-master03 Ready control-plane 8m41s v1.25.3 k8s-node01 Ready <none> 6m54s v1.25.3 k8s-node02 Ready <none> 6m31s v1.25.3 k8s-node03 Ready <none> 6m5s v1.25.3 ?
9、部署nginx测试 [root@k8s-master01 ~]#kubectl create deployment nginx --image nginx:alpine --replicas=3 deployment.apps/nginx created ? [root@k8s-master01 ~]#kubectl get pods NAME READY STATUS RESTARTS AGE nginx-55f494c486-4js9n 1/1 Running 0 58s nginx-55f494c486-fsgxq 1/1 Running 0 58s nginx-55f494c486-z2gzv 1/1 Running 0 58s ? [root@k8s-master01 ~]#kubectl get pods -o wide NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES nginx-55f494c486-4js9n 1/1 Running 0 4m31s 10.244.3.2 k8s-node01 <none> <none> nginx-55f494c486-fsgxq 1/1 Running 0 4m31s 10.244.4.2 k8s-node02 <none> <none> nginx-55f494c486-z2gzv 1/1 Running 0 4m31s 10.244.5.2 k8s-node03 <none> <none> ? [root@k8s-master01 ~]#curl 10.244.4.2 <!DOCTYPE html> <html> <head> <title>Welcome to nginx!</title> <style> html { color-scheme: light dark; } body { width: 35em; margin: 0 auto; font-family: Tahoma, Verdana, Arial, sans-serif; } </style> </head> <body> <h1>Welcome to nginx!</h1> <p>If you see this page, the nginx web server is successfully installed and working. Further configuration is required.</p> ? <p>For online documentation and support please refer to <a href="http://nginx.org/">nginx.org</a>.<br/> Commercial support is available at <a href="http://nginx.com/">nginx.com</a>.</p> ? <p><em>Thank you for using nginx.</em></p> </body> </html> ? ? #删除pod,自动拉起 [root@k8s-master01 ~]#kubectl delete pods nginx-55f494c486-fsgxq pod "nginx-55f494c486-fsgxq" deleted ? [root@k8s-master01 ~]#kubectl get pods -owide NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES nginx-55f494c486-4js9n 1/1 Running 0 11m 10.244.3.2 k8s-node01 <none> <none> nginx-55f494c486-xqcph 1/1 Running 0 16s 10.244.4.3 k8s-node02 <none> <none> nginx-55f494c486-z2gzv 1/1 Running 0 11m 10.244.5.2 k8s-node03 <none> <none> ?
推荐阅读
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 小米10S、荣耀60和小米civi怎么选-购机建议
- vivoy31s和iqoou3哪个好_vivoy31s和iqoou3对比
- 皮新字组词|皮的新字和组词
- 小米air2se和红米airdots2区别_小米air2se和红米airdots2哪个好
- 小米10和小米10s拍照对比_小米10和小米10s哪个拍照好
- 兰蔻505和迪奥999对比_兰蔻505和迪奥999哑光试色
- 基于 Docker 构建轻量级 CI 系统:Gitea 与 Woodpecker CI 集成
- 使用LabVIEW实现基于pytorch的DeepLabv3图像语义分割
- vivo s9和vivo x60哪个好_哪个性价比高
- FrameLess Qt--无边框窗口完美实现,包含缩放和移动功能重写。