vi /etc/sysconfig/flanneld
# Flanneld configuration options
# etcd url location. Point this to the server where etcd runs
FLANNEL_ETCD_ENDPOINTS="http://etcd:2379"
# etcd config key. This is the configuration key that flannel queries
# For address range assignment
FLANNEL_ETCD_PREFIX="/atomic.io/network"
# Any additional options that you want to pass
#FLANNEL_OPTIONS=""
创建dashboard
kubectl create -f kubernetes-dashboard.yaml
kubectl get -f kubernetes-dashboard.yaml
发现deploy/kubernetes-dashboard-latest一直不在avaiable状态,通过下面命令查询
kubectl get pods --all-namespaces 发现kube-system的命名空间下,总是有个kubernetes-dashboard-latest-1590787137-pp8qd处于CrashLoopBackOff状态.
可以通过下面命令查看namespace的日志情况
kubectl describe po kubernetes-dashboard --namespace=kube-system 删除kubernetes-dashboard
因为没搞清楚什么原因,很想再试一次,删除命令如下:
kubectl delete -f kubernetes-dashboard.yaml 在运行kubectl get pods --all-namespaces发现总是有kube-system命名空间下的pod在运行.最后通过指定命名空间删除
kubectl delete --all pods --namespace=kube-system
kubectl delete deployment kubernetes-dashboard --namespace=kube-system
注意,如果只删除pod会发现删完后又会有个同样的pod启动起来,删除deployment即可. 查看日志确定原因
最重要还是要看日志,最重要还是要看日志,最重要还是要看日志, 重要事情说三遍,此问题浪费3个钟头时间 :( kubectl logs -f kubernetes-dashboard-latest-3243398-thc7k -n kube-system [iyunv@k8s-master ~]# kubectl logs -f kubernetes-dashboard-latest-3243398-thc7k -n kube-system Using HTTP port: 9090 Using apiserver-host location: http://k8s-master:8080 Creating API server client for http://k8s-master:8080 Error while initializing connection to Kubernetes apiserver. This most likely means that the cluster is misconfigured (e.g., it has invalid apiserver certificates or service accounts configuration) or the --apiserver-host param points to a server that does not exist. Reason: Get http://k8s-master:8080/version: dial tcp: lookup k8s-master on 202.96.134.33:53: no such host Refer to the troubleshooting guide for more information: https://github.com/kubernetes/dashboard/blob/master/docs/user-guide/troubleshooting.md
发现是dns把k8s-master解析成202.96.134.33的地址了,修改kubernetes-dashboard.yaml中的apiserver-host=http://k8s-master:8080为
http://192.168.0.104:8080后,再进行create就成功.