Skip to main content

2、安装dashboard

安装kubernetes-dashboard(1.8.3)部署与踩坑

一、下载kubernetes-dashboard.yaml文件

wget https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard.yaml

docker pull registry.cn-hangzhou.aliyuncs.com/jonny/kubernetes-dashboard-amd64:v1.8.3

修改kubernetes-dashboard.yaml文件

搜索image 把 镜像地址改为 registry.cn-hangzhou.aliyuncs.com/jonny/kubernetes-dashboard-amd64:v1.8.3

安装

kubectl apply -f kubernetes-dashboard.yaml

查看启动状态

kubectl get pods --all-namespaces

二、创建用户

  1. 创建admin用户

新建admin-user.yaml文件,内容如下:

apiVersion: v1 kind: ServiceAccount metadata: name: admin-user namespace: kube-system

执行创建命令:

kubectl create -f admin-user.yaml

  1. 绑定角色

新建admin-user-role-binding.yaml文件,内容如下:

执行创建命令:

kubectl create -f admin-user-role-binding.yaml

  1. 获取该admin用户的访问token

kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep admin-user | awk '{print $1}')

token: eyJhbGciOiJSUzI1NiIsImtpZCI6IiJ9.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlLXN5c3RlbSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJhZG1pbi11c2VyLXRva2VuLTR0dHdqIiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQubmFtZSI6ImFkbWluLXVzZXIiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC51aWQiOiJiMzMwZDBjZC1kYWMwLTExZTgtYjQ5ZS0wMjUzMTczY2RlODAiLCJzdWIiOiJzeXN0ZW06c2VydmljZWFjY291bnQ6a3ViZS1zeXN0ZW06YWRtaW4tdXNlciJ9.aldu6SArfwHNfsd69IOtPWlrt3y_VX1H6BxS3FTC8NBsmDbNGHNtSlGqDMa0TlmMi5lLN7LkEWGDjC1raTPjITaDEItp3IaC4vx3ZspHka1nsaY6zi5Pp6Gwlrn8JA5wUsUaF-fe9Qe5nFz_1zBqBWwQ3IpjgBJdOLc3qt-5DZBwNSjCMX6bDhQ1X2GidKSxTMWw5CG1CWCA6zTg0XAe1svKtzW_Dl4qZH-BUfC0R-p0C2wWDFuzlZrfdy6pINHWAyBikYNozspFcrSVFlLDsfNwjcbJtqLgqIGeACejW5N0hhYif9FS7jmj-W6RY0GHGGI9a3uCnnqI9g14MmrS8g

集成Heapster插件

kubectl create -f http://mirror.faasx.com/kubernetes/heapster/deploy/kube-config/influxdb/influxdb.yaml kubectl create -f http://mirror.faasx.com/kubernetes/heapster/deploy/kube-config/influxdb/grafana.yaml kubectl create -f http://mirror.faasx.com/kubernetes/heapster/deploy/kube-config/influxdb/heapster.yaml kubectl create -f http://mirror.faasx.com/kubernetes/heapster/deploy/kube-config/rbac/heapster-rbac.yaml

使用的yaml文件是 https://github.com/kubernetes/heapster/tree/master/deploy/kube-config/influxdb 的国内镜像

外部访问

kubectl proxy --address='0.0.0.0' --accept-hosts='^*$'

kubectl proxy --address='10.102.17.155' --port=8086 --accept-hosts='^*$'

访问

http://192.168.111.111:8001/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/#!/login

删除安装的 Dashboard 配置命令:

$ kubectl -n kube-system delete $(kubectl -n kube-system get pod -o name | grep dashboard)

编辑

kubectl -n kube-system edit service kubernetes-dashboard

NodePort访问

kubectl patch svc kubernetes-dashboard -p '{"spec":{"type":"NodePort"}}' -n kube-system

kubectl patch svc monitoring-grafana -p '{"spec":{"type":"NodePort"}}' -n kube-system

kubectl patch svc monitoring-influxdb -p '{"spec":{"type":"NodePort"}}' -n kube-system

查看开放端口

kubectl get svc -n kube-system

kubectl get nodes,svc,pods -n kube-system -o wide

删除kubectl delete -f *.yaml

参考文档:

kubernetes-dashboard(1.8.3)部署与踩坑

https://www.cnblogs.com/RainingNight/p/deploying-k8s-dashboard-ui.html