这个时候呢,我们可以通过kubectl看看集群当前的状态:
root@xyq-k8s-master:/home/administrator# kubectl get nodes NAME STATUS AGE xyq-k8s-master Ready,master 1m root@xyq-k8s-master:/home/administrator# kubectl get pods --all-namespaces NAMESPACE NAME READY STATUS RESTARTS AGE kube-system dummy-2088944543-gjmv4 1/1 Running 0 1m kube-system etcd-xyq-k8s-master 0/1 Pending 0 2s kube-system kube-apiserver-xyq-k8s-master 1/1 Running 0 20s kube-system kube-controller-manager-xyq-k8s-master 1/1 Running 0 22s kube-system kube-discovery-1769846148-9dpvt 1/1 Running 0 1m kube-system kube-dns-2924299975-lc4rr 0/4 ContainerCreating 0 1m kube-system kube-proxy-w5v9m 1/1 Running 0 1m kube-system kube-scheduler-xyq-k8s-master 0/1 Pending 0 4s可以看出来,除了kube-dns之外,其他pods都跑起来了。是因为在没有部署集群网络时,dns是起不来的。So我们进入下一步!
(3/4)初始化master官方一共给出了五种网络addon,我选了Weave Net(因为它的安装步骤最方便诶嘿嘿=。=),直接运行:
kubectl apply -f https://git.io/weave-kube等weave跑起来后,kube-dns自然就跑起来啦。
root@xyq-k8s-master:/home/administrator# kubectl apply -f https://git.io/weave-kube daemonset "weave-net" created root@xyq-k8s-master:/home/administrator# kubectl get pods --all-namespaces NAMESPACE NAME READY STATUS RESTARTS AGE kube-system dummy-2088944543-gjmv4 1/1 Running 0 3m kube-system etcd-xyq-k8s-master 1/1 Running 3 1m kube-system kube-apiserver-xyq-k8s-master 1/1 Running 0 2m kube-system kube-controller-manager-xyq-k8s-master 1/1 Running 0 2m kube-system kube-discovery-1769846148-9dpvt 1/1 Running 0 3m kube-system kube-dns-2924299975-lc4rr 4/4 Running 0 3m kube-system kube-proxy-w5v9m 1/1 Running 0 3m kube-system kube-scheduler-xyq-k8s-master 1/1 Running 0 1m kube-system weave-net-8j1zg 2/2 Running 0 1m (4/4)将其他节点加入集群分别ssh到node1和node2上去,以root用户运行:
kubeadm join --token=yiqian.123456 192.168.0.158再回到我们的master节点查看nodes,就会发现集群已经搭好了。
root@xyq-k8s-master:/home/administrator# kubectl get nodes NAME STATUS AGE xyq-k8s-master Ready,master 10m xyq-k8s-s1 Ready 5m xyq-k8s-s2 Ready 5m 关于翻墙由于我是在远程服务器上搭建虚拟机然后ssh上去操作,所以不能设置全局代理,只能把http proxy加到docker的配置文件/etc/default/docker中:
export http_proxy=<这个不能告诉你> export https_proxy=<这个也不能告诉你>