当前位置:  首页>> 技术小册>> Kubernetes合辑1-安装Kubernetes

CNI插件的选择比较多,通常在非大规模集群中,我们可以有把握的说,所有的节点都会在同一个VPC中,各个节点之间的通信不需要跨路由,这种场景我个人推荐简单的 flannel 插件的 host-gw 模式。

为了方便,此处选择安装Flannel作为插件,github地址:https://github.com/coreos/flannel

安装指导: https://github.com/coreos/flannel/blob/master/Documentation/kubernetes.md

Flannel的网络模式:https://github.com/flannel-io/flannel/blob/master/Documentation/backends.md

  1. [root@maxiaoke flannel]# wget https://raw.githubusercontent.com/flannel-io/flannel/master/Documentation/kube-flannel.yml
  2. # 需要修改一下内容:
  3. # 1. Network 必须要是Pod CIDR,这个在 kubeadm init 时指定的
  4. # 2. Type 是指flannel backend,推荐使用 host-gw
  5. # 3. flannel 的镜像,当前版本默认使用的是 rancher 仓库,这里就不再修改了
  6. [root@maxiaoke flannel]# grep -Ew "Type|image|Network" kube-flannel.yml
  7. "Network": "10.200.0.0/16",
  8. "Type": "host-gw"
  9. #image: flannelcni/flannel-cni-plugin:v1.0.1 for ppc64le and mips64le (dockerhub limitations may apply)
  10. image: rancher/mirrored-flannelcni-flannel-cni-plugin:v1.0.1
  11. #image: flannelcni/flannel:v0.17.0 for ppc64le and mips64le (dockerhub limitations may apply)
  12. image: rancher/mirrored-flannelcni-flannel:v0.17.0
  13. #image: flannelcni/flannel:v0.17.0 for ppc64le and mips64le (dockerhub limitations may apply)
  14. image: rancher/mirrored-flannelcni-flannel:v0.17.0
  15. [root@maxiaoke flannel]# kubectl apply -f kube-flannel.yml
  1. [root@maxiaoke deploy-kubernetes]# kubectl get node -o wide
  2. NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
  3. master-81 Ready control-plane,master 9h v1.23.6 10.4.7.81 <none> CentOS Linux 7 (Core) 5.4.203-1.el7.elrepo.x86_64 containerd://1.6.4
  4. worker-84 Ready <none> 9h v1.23.6 10.4.7.84 <none> CentOS Linux 7 (Core) 5.4.203-1.el7.elrepo.x86_64 containerd://1.6.4
  5. worker-85 Ready <none> 9h v1.23.6 10.4.7.85 <none> CentOS Linux 7 (Core) 5.4.203-1.el7.elrepo.x86_64 containerd://1.6.4
  6. worker-86 Ready <none> 9h v1.23.6 10.4.7.86 <none> CentOS Linux 7 (Core) 5.4.203-1.el7.elrepo.x86_64 containerd://1.6.4
  7. worker-87 Ready <none> 9h v1.23.6 10.4.7.87 <none> CentOS Linux 7 (Core) 5.4.203-1.el7.elrepo.x86_64 containerd://1.6.4
  8. worker-88 Ready <none> 9h v1.23.6 10.4.7.88 <none> CentOS Linux 7 (Core) 5.4.203-1.el7.elrepo.x86_64 containerd://1.6.4
  9. [root@maxiaoke deploy-kubernetes]# kubectl get pod -n kube-system | grep core # coredns 可以正常运行了
  10. coredns-6d8c4cb4d-mqgk4 1/1 Running 0 25m
  11. coredns-6d8c4cb4d-nxr8r 1/1 Running 0 9h

该分类下的相关小册推荐: