在github.com上可以查看到最新的kubernetes-dashboard但是所有镜像来源于gcr.io,无奈因为墙的问题无法下载。

如果因为墙的问题无法下载,可手动更改镜像地址即可。
https://github.com/mritd/gcr
这个项目每天会自动构建最新的gcr镜像
kubernetes-dashboard的项目地址为
https://github.com/kubernetes/dashboard

首先下载官方的yaml文件
wget https://raw.githubusercontent.com/kubernetes/dashboard/v1.10.0/src/deploy/recommended/kubernetes-dashboard.yaml

sed -i 's#k8s.gcr.io#gcrxio#g' kubernetes-dashboard.yaml

kubectl apply -f kubernetes-dashboard.yaml

kubectl get pods -nkube-system
NAME READY STATUS RESTARTS AGE
coredns-55f86bf584-64fm7 1/1 Running 0 6h
coredns-55f86bf584-ffhtt 1/1 Running 0 6h
kubernetes-dashboard-7588787688-ddh77 1/1 Running 0 39s

如果需要开放到nodeport访问的话就需要修改service部分为

kind: Service
apiVersion: v1
metadata:
  labels:
    k8s-app: kubernetes-dashboard
  name: kubernetes-dashboard
  namespace: kube-system
spec:
  type: NodePort
  ports:
    - port: 443
      targetPort: 8443
      nodePort: 30443
  selector:
    k8s-app: kubernetes-dashboard

这样就可以通过外网的80443端口访问(建议使用火狐浏览器,chrome以及ie打开都是由问题的)

在外网访问的时候,发现需要提示token,于是我们创建一个admin-token。

kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
  name: admin
  annotations:
    rbac.authorization.kubernetes.io/autoupdate: "true"
roleRef:
  kind: ClusterRole
  name: cluster-admin
  apiGroup: rbac.authorization.k8s.io
subjects:
- kind: ServiceAccount
  name: admin
  namespace: kube-system
---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: admin
  namespace: kube-system
  labels:
    kubernetes.io/cluster-service: "true"
    addonmanager.kubernetes.io/mode: Reconcile

通过如下脚本去获取token
kubectl describe secret/$(kubectl get secret -nkube-system |grep admin|awk '{print $1}') -nkube-system

kubernetes 1.11.2安装kubernetes-dashboard

kubernetes 1.11.2安装kubernetes-dashboard