# 查看系统pods
[root@master ~]# kubectl get pods -n kube-system
NAME READY STATUS RESTARTS AGE
etcd-master 0/1 Pending 0 1s
kube-apiserver-master 0/1 Pending 0 1s
kube-controller-manager-master 0/1 Pending 0 1s
kube-dns-86f4d74b45-d42zm 0/3 Pending 0 8h
kube-proxy-884h6 1/1 NodeLost 0 8h
kube-scheduler-master 0/1 Pending 0 1s
# 查看集群各组件状态信息
[root@master ~]# kubectl get componentstatuses
NAME STATUS MESSAGE ERROR
scheduler Healthy ok
controller-manager Healthy ok
etcd-0 Healthy {"health": "true"}
You have new mail in /var/spool/mail/root
三、node加入集群
# 确保node节点cgroup驱动保持一致
sed -i "s/cgroup-driver=systemd/cgroup-driver=cgroupfs/g" /etc/systemd/system/kubelet.service.d/10-kubeadm.conf
# 命令来自集群初始化之后额显示中
kubeadm join 192.168.1.78:6443 --token v0866r.u7kvg5js1ah2u1bi --discovery-token-ca-cert-hash sha256:7b36794f4fa5121f6a5e309d0e312ded72997a88236a93ec7da3520e5aaccf0e
# master节点查看nodes信息
[root@master data]# kubectl get nodes
NAME STATUS ROLES AGE VERSION
master NotReady master 57m v1.10.1
node1 NotReady <none> 27m v1.10.1
node2 NotReady <none> 11s v1.10.1
node3 NotReady <none> 4s v1.10.1
You have new mail in /var/spool/mail/root
四、部署网络
部署
flannel官网
flannel下载时不用科学上网,flannel的yml文件会自动去quay.io网站中下载镜像。
# 1.1使用软件包中的flannel,并指pod映射到哪个主机的网卡上面。
vim kube-flannel.yml
command: [ "/opt/bin/flanneld", "--ip-masq", "--kube-subnet-mgr","-iface=eth0" ]
# 以下要按顺序创建,先创建rbac,之前没有穿件rbac导致pod正常创建,但是pin不同
kubectl apply -f kube-flannel-rbac.yml
kubectl apply -f kube-flannel.yml
# 后,节点的状态会变为ready
[root@master1 kubernetes1.10]# kubectl get node
NAME STATUS ROLES AGE VERSION
master Ready master 57m v1.10.1
node1 Ready <none> 27m v1.10.1
node2 Ready <none> 11s v1.10.1
node3 Ready <none> 4s v1.10.1
# 2.从官网下载最新的flannel,k8s1.7+ 直接执行以下命令即可
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
flannel配置文件修改
kube-flannel.yml中指定使用的网段
"Network": "10.244.0.0/16"
默认使用16位掩码,则在各node中都分配一个10.244.0.0/8的网络
五、部署dashboard
kubectl apply -f kubernetes-dashboard-http.yam
kubectl apply -f admin-role.yaml
kubectl apply -f kubernetes-dashboard-admin.rbac.yaml
命令行常用命令
# 查看pod信息,默认显示default名称空间下的pod
[root@master ~]# kubectl get pods
No resources found.
# 指定名称空间写pod
[root@master ~]# kubectl get pods -n kube-system
NAME READY STATUS RESTARTS AGE
etcd-master 1/1 Running 0 3h
kube-apiserver-master 1/1 Running 0 3h
kube-controller-manager-master 1/1 Running 0 3h
kube-dns-86f4d74b45-bzbvc 3/3 Running 0 3h
kube-flannel-ds-5ghhj 1/1 Running 0 2h
kube-flannel-ds-ht4xd 1/1 Running 0 3h
kube-flannel-ds-kbm5g 1/1 Running 0 3h
kube-flannel-ds-mlj4r 1/1 Running 0 2h
kube-proxy-9xxnd 1/1 Running 0 3h
kube-proxy-n9w5x 1/1 Running 0 3h
kube-proxy-nkn8c 1/1 Running 0 2h
kube-proxy-shd6l 1/1 Running 0 2h
kube-scheduler-master 1/1 Running 0 3h
kubernetes-dashboard-5c469b58b8-rjfx6 1/1 Running 0 1h