完全按照老师的教程安装,使用 kubeadm 方式。

资源规划

名称 ip 资源配置
master 192.168.163.100 2c,2u,50g
node1 192.168.163.101 2c,2u,50g
node2 192.168.163.102 2c,2u,50g

VMware 安装环境系统

系统 CentOS:CentOS-7-x86_64-DVD-1804.iso

先安装master,后面使用 VMware 的虚拟机复制,编辑 hostname 和 编辑 IP 配置。
编辑hostname: vim /etc/hostname
编辑ip:vim /etc/sysconfig/network-scripts/ifconfig-ens33

参考:VMware 如何通过现有虚拟机克隆新的虚拟机 (图文)

统一用户名 root,密码 123456(只是为了测试方便而已)

kubectl apply -f kube-flannel.yml 报错

不知道,怎么就好了,参考了一下 K8s 配置网络插件flannel
调整 kube-flannel.yml

  1. net-conf.json: |
  2. {
  3. "Network": "10.244.0.0/16",
  4. "Backend": {
  5. "Type": "vxlan",
  6. "Directrouting":true #新加
  7. }

和 kubectl delete -f kube-flannel.yml

  1. [root@master ~]# kubectl apply -f kube-flannel.yml
  2. podsecuritypolicy.policy/psp.flannel.unprivileged created
  3. clusterrole.rbac.authorization.k8s.io/flannel created
  4. clusterrolebinding.rbac.authorization.k8s.io/flannel created
  5. serviceaccount/flannel created
  6. configmap/kube-flannel-cfg created
  7. daemonset.apps/kube-flannel-ds created
  8. [root@master ~]# kubectl get nodes
  9. NAME STATUS ROLES AGE VERSION
  10. master NotReady master 2m35s v1.17.4
  11. node1 NotReady <none> 110s v1.17.4
  12. node2 NotReady <none> 106s v1.17.4
  13. [root@master ~]# kubectl apply -f kube-flannel.yml
  14. podsecuritypolicy.policy/psp.flannel.unprivileged configured
  15. clusterrole.rbac.authorization.k8s.io/flannel unchanged
  16. clusterrolebinding.rbac.authorization.k8s.io/flannel unchanged
  17. serviceaccount/flannel unchanged
  18. configmap/kube-flannel-cfg unchanged
  19. daemonset.apps/kube-flannel-ds unchanged
  20. [root@master ~]# vim kube-flannel.yml
  21. [root@master ~]#
  22. [root@master ~]#
  23. [root@master ~]#
  24. [root@master ~]# kubectl apply -f kube-flannel.yml
  25. podsecuritypolicy.policy/psp.flannel.unprivileged configured
  26. clusterrole.rbac.authorization.k8s.io/flannel unchanged
  27. clusterrolebinding.rbac.authorization.k8s.io/flannel unchanged
  28. serviceaccount/flannel unchanged
  29. configmap/kube-flannel-cfg unchanged
  30. daemonset.apps/kube-flannel-ds configured
  31. [root@master ~]# vim kube-flannel.yml
  32. [root@master ~]#
  33. [root@master ~]# ip router show
  34. Object "router" is unknown, try "ip help".
  35. [root@master ~]# ip route show
  36. default via 192.168.163.2 dev ens33 proto static metric 100
  37. 10.244.0.0/24 dev cni0 proto kernel scope link src 10.244.0.1
  38. 10.244.1.0/24 via 10.244.1.0 dev flannel.1 onlink
  39. 10.244.2.0/24 via 10.244.2.0 dev flannel.1 onlink
  40. 172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1
  41. 192.168.163.0/24 dev ens33 proto kernel scope link src 192.168.163.100 metric 100
  42. [root@master ~]# ls -a
  43. . .bash_history .bashrc .cshrc .pki
  44. .. .bash_logout .cache .kube .tcshrc
  45. anaconda-ks.cfg .bash_profile .config kube-flannel.yml .viminfo
  46. [root@master ~]# ll -a
  47. 总用量 44
  48. dr-xr-x---. 6 root root 229 6 28 11:17 .
  49. dr-xr-xr-x. 17 root root 224 6 28 10:12 ..
  50. -rw-------. 1 root root 1281 6 28 10:12 anaconda-ks.cfg
  51. -rw-------. 1 root root 2925 6 28 11:01 .bash_history
  52. -rw-r--r--. 1 root root 18 12 29 2013 .bash_logout
  53. -rw-r--r--. 1 root root 176 12 29 2013 .bash_profile
  54. -rw-r--r--. 1 root root 176 12 29 2013 .bashrc
  55. drwxr-xr-x. 3 root root 18 6 28 10:16 .cache
  56. drwxr-xr-x. 3 root root 18 6 28 10:16 .config
  57. -rw-r--r--. 1 root root 100 12 29 2013 .cshrc
  58. drwxr-xr-x 4 root root 51 6 28 11:09 .kube
  59. -rw-r--r-- 1 root root 4879 6 28 11:24 kube-flannel.yml
  60. drwxr----- 3 root root 19 6 28 10:50 .pki
  61. -rw-r--r--. 1 root root 129 12 29 2013 .tcshrc
  62. -rw------- 1 root root 5294 6 28 11:17 .viminfo
  63. [root@master ~]# kubectl apply -f kube-flannel.yml
  64. podsecuritypolicy.policy/psp.flannel.unprivileged configured
  65. clusterrole.rbac.authorization.k8s.io/flannel unchanged
  66. clusterrolebinding.rbac.authorization.k8s.io/flannel unchanged
  67. serviceaccount/flannel unchanged
  68. configmap/kube-flannel-cfg configured
  69. daemonset.apps/kube-flannel-ds unchanged
  70. [root@master ~]# kubectl delete -f kube-flannel.yml
  71. podsecuritypolicy.policy "psp.flannel.unprivileged" deleted
  72. clusterrole.rbac.authorization.k8s.io "flannel" deleted
  73. clusterrolebinding.rbac.authorization.k8s.io "flannel" deleted
  74. serviceaccount "flannel" deleted
  75. configmap "kube-flannel-cfg" deleted
  76. daemonset.apps "kube-flannel-ds" deleted
  77. [root@master ~]# kubectl apply -f kube-flannel.yml
  78. podsecuritypolicy.policy/psp.flannel.unprivileged created
  79. clusterrole.rbac.authorization.k8s.io/flannel created
  80. clusterrolebinding.rbac.authorization.k8s.io/flannel created
  81. serviceaccount/flannel created
  82. configmap/kube-flannel-cfg created
  83. daemonset.apps/kube-flannel-ds created
  84. [root@master ~]# kubeadm get nodes
  85. unknown command "get" for "kubeadm"
  86. To see the stack trace of this error execute with --v=5 or higher
  87. [root@master ~]# kubectl get nodes
  88. NAME STATUS ROLES AGE VERSION
  89. master Ready master 17m v1.17.4
  90. node1 Ready <none> 17m v1.17.4
  91. node2 Ready <none> 17m v1.17.4