此前,根据在CentOS 7.2上部署Kubernetes集群 已部署一个可用Kubernetes集群,在这篇文章中将介绍如何为该集群搭建可视化界面。
部署Kubernetes Dashboard
根据kubernetes github的介绍下载部署Kubernetes Dashboard的资源文件:
# wget https://git.io/kube-dashboard-no-rbac
# mv kube-dashboard-no-rbac kube-dashboard-no-rbac.yaml
然后参照下面的内容编辑该文件:
...
args:
# Uncomment the following line to manually specify Kubernetes API server Host
# If not specified, Dashboard will attempt to auto discover the API server and connect
# to it. Uncomment only if the default does not work.
- --apiserver-host=http://192.168.120.121:8080
...
最后执行kubectl命令创建pod:
# kubectl create -f kube-dashboard-no-rbac.yaml
deployment "kubernetes-dashboard" created
service "kubernetes-dashboard" created
根据该资源文件中spec.template.spec.containers.image的值gcr.io/google_containers/kubernetes-dashboard-amd64:v1.6.1
可知用于创建容器的镜像位于境外的仓库,因此必须先配置工作节点可以访问境外的网站。
问题解决
现在,使用kubectl命令检查已创建的pod状态是否正常:
# kubectl get pods --all-namespaces -o wide | grep dashboard
kube-system kubernetes-dashboard-3951142596-drt8r 0/1 CrashLoopBackOff 14 1m 172.30.103.4 kube-node3
可以看到kubernetes-dashboard-3951142596-drt8r
的状态为CrashLoopBackOff
,即该pod未正常运行。那么是什么原因导致发生这种情况?在该pod的绑定工作节点kube-node3上查看日志文件/var/log/messages:
...
May 27 10:34:45 kube-node3 journal: Creating in-cluster Heapster client
May 27 10:34:45 kube-node3 journal: E0527 02:34: