我用的是kubespray(v2.11.0) install kubernetes(1.14.0)。我有3个vm。(计划2个master,1个节点)由于网络原因,我使用了内部的image repo和storage server。然后我执行“ansible-playbook -i inventory/mycluster/hosts.yaml --become --become-user=root cluster.yml”命令。第一次,它在node2上失败了。因为任务:[kubernetes-apps/network_plugin/flannel : Flannel | 等待 flannel subnet.env 文件存在]。错误是超时等待。但我执行“kubectl get nodes”我得到了这个:
root@node1:~/kubespray# kubectl get nodes
NAME STATUS ROLES AGE VERSION
node1 Ready master 22h v1.14.0
node3 Ready <none> 69m v1.14.0
所以我认为可能我应该将第一个 master 的文件复制到第二个主节点。
scp node1:/run/flannel/subnet.env node2:/run/flannel
然后我再次执行命令“ansible-playbook -i inventory/mycluster/hosts.yaml --become --become-user=root cluster.yml”。这次所有的任务都ok了。没有失败。但我仍然无法在 kubernetes 中获取 node2。您可以在下面看到。
TASK [kubernetes/preinstall : run growpart] *******************************************************************************************************************************
Sunday 11 October 2020 22:20:34 -0400 (0:00:00.085) 0:05:19.550 ********
TASK [kubernetes/preinstall : run xfs_growfs] *****************************************************************************************************************************
Sunday 11 October 2020 22:20:34 -0400 (0:00:00.084) 0:05:19.635 ********
PLAY RECAP ****************************************************************************************************************************************************************
localhost : ok=1 changed=0 unreachable=0 failed=0
node1 : ok=533 changed=24 unreachable=0 failed=0
node2 : ok=608 changed=33 unreachable=0 failed=0
node3 : ok=454 changed=20 unreachable=0 failed=0
Sunday 11 October 2020 22:20:34 -0400 (0:00:00.069) 0:05:19.704 ********
===============================================================================
kubernetes/client : Generate admin kubeconfig with external api endpoint ------------------------------------------------------------------------------------------ 10.37s
download : download_container | Download image if required --------------------------------------------------------------------------------------------------------- 7.51s
kubernetes-apps/network_plugin/flannel : Flannel | Wait for flannel subnet.env file presence ----------------------------------------------------------------------- 5.19s
etcd : wait for etcd up -------------------------------------------------------------------------------------------------------------------------------------------- 4.46s
container-engine/docker : ensure docker packages are installed ----------------------------------------------------------------------------------------------------- 4.13s
kubernetes-apps/ansible : Kubernetes Apps | Start Resources -------------------------------------------------------------------------------------------------------- 3.47s
kubernetes-apps/ingress_controller/ingress_nginx : NGINX Ingress Controller | Apply manifests ---------------------------------------------------------------------- 2.48s
kubernetes-apps/ansible : Kubernetes Apps | Lay Down CoreDNS Template ---------------------------------------------------------------------------------------------- 2.39s
kubernetes/master : kubeadm | write out kubeadm certs -------------------------------------------------------------------------------------------------------------- 2.29s
etcd : reload etcd ------------------------------------------------------------------------------------------------------------------------------------------------- 2.04s
kubernetes-apps/ingress_controller/ingress_nginx : NGINX Ingress Controller | Create manifests --------------------------------------------------------------------- 2.00s
download : download | Download files / images ---------------------------------------------------------------------------------------------------------------------- 1.71s
bootstrap-os : Fetch /etc/os-release ------------------------------------------------------------------------------------------------------------------------------- 1.52s
kubernetes/master : slurp kubeadm certs ---------------------------------------------------------------------------------------------------------------------------- 1.44s
bootstrap-os : Install dbus for the hostname module ---------------------------------------------------------------------------------------------------------------- 1.11s
kubernetes/master : Backup old certs and keys ---------------------------------------------------------------------------------------------------------------------- 1.08s
download : download | Download files / images ---------------------------------------------------------------------------------------------------------------------- 1.04s
download : download_file | Download item --------------------------------------------------------------------------------------------------------------------------- 0.98s
download : download | Sync files / images from ansible host to nodes ----------------------------------------------------------------------------------------------- 0.95s
container-engine/docker : Ensure old versions of Docker are not installed. | Debian -------------------------------------------------------------------------------- 0.93s
root@node1:~/kubespray# kc get nodes
The program 'kc' is currently not installed. You can install it by typing:
apt install kimwitu
root@node1:~/kubespray# kubectl get nodes
NAME STATUS ROLES AGE VERSION
node1 Ready master 22h v1.14.0
node3 Ready <none> 69m v1.14.0
root@node1:~/kubespray#
有人告诉我如何解决和调试这个问题。