Dashboard部署

dashboard项目地址:https://github.com/kubernetes/dashboard

  1. 部署dashboard

    1. kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v1.10.1/src/deploy/recommended/kubernetes-dashboard.yaml
  2. 开启k8s代理

kubectl proxy

  1. 可在以下地址访问dashboard界面

http://localhost:8001/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/
K8s Dashboard - 图1

  1. 为了获取token,需创建用户
  • 首先创建一个叫admin-user的服务账号,并放在kube-system名称空间下:

  • ``` vim admin-user.yaml

admin-user.yaml

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

kubectl create -f admin-user.yaml

  1. >
  2. - 绑定角色,默认情况下,`kubeadm`创建集群时已经创建了`admin`角色,直接绑定即可:
  3. - <br />

vim admin-user-role-binding.yaml

admin-user-role-binding.yaml

apiVersion: rbac.authorization.k8s.io/v1beta1 kind: ClusterRoleBinding metadata: name: admin-user roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: cluster-admin subjects:

  • kind: ServiceAccount name: admin-user namespace: kube-system

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

  1. 找到token

    1. kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep admin-user | awk '{print $1}')
    输出类似:
  1. Name: admin-user-token-qrj82
  2. Namespace: kube-system
  3. Labels: <none>
  4. Annotations: kubernetes.io/service-account.name=admin-user
  5. kubernetes.io/service-account.uid=6cd60673-4d13-11e8-a548-00155d000529
  6. Type: kubernetes.io/service-account-token
  7. Data
  8. ====
  9. token: eyJhbGciOiJSUzI1NiIsImtpZCI6IiJ9.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlLXN5c3RlbSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJhZG1pbi11c2VyLXRva2VuLXFyajgyIiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQubmFtZSI6ImFkbWluLXVzZXIiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC51aWQiOiI2Y2Q2MDY3My00ZDEzLTExZTgtYTU0OC0wMDE1NWQwMDA1MjkiLCJzdWIiOiJzeXN0ZW06c2VydmljZWFjY291bnQ6a3ViZS1zeXN0ZW06YWRtaW4tdXNlciJ9.C5mjsa2uqJwjscWQ9x4mEsWALUTJu3OSfLYecqpS1niYXxp328mgx0t-QY8A7GQvAr5fWoIhhC_NOHkSkn2ubn0U22VGh2msU6zAbz9sZZ7BMXG4DLMq3AaXTXY8LzS3PQyEOCaLieyEDe-tuTZz4pbqoZQJ6V6zaKJtE9u6-zMBC2_iFujBwhBViaAP9KBbE5WfREEc0SQR9siN8W8gLSc8ZL4snndv527Pe9SxojpDGw6qP_8R-i51bP2nZGlpPadEPXj-lQqz4g5pgGziQqnsInSMpctJmHbfAh7s9lIMoBFW7GVE8AQNSoLHuuevbLArJ7sHriQtDB76_j4fmA
  10. ca.crt: 1025 bytes
  11. namespace: 11 bytes
  1. 输入token,界面如下:

K8s Dashboard - 图2

集成Heapster

heapster项目地址:https://github.com/kubernetes-retired/heapster

  1. 使用influxdb作为存储:

    1. kubectl create -f http://mirror.faasx.com/kubernetes/heapster/deploy/kube-config/influxdb/influxdb.yaml
    2. kubectl create -f http://mirror.faasx.com/kubernetes/heapster/deploy/kube-config/influxdb/grafana.yaml
  2. 为了正常显示监控数据,需修改以下两个文件:


  3. ``` wget http://mirror.faasx.com/kubernetes/heapster/deploy/kube-config/influxdb/heapster.yaml wget http://mirror.faasx.com/kubernetes/heapster/deploy/kube-config/rbac/heapster-rbac.yaml

vim heapster.yaml …修改source部分 —source=kubernetes:https://kubernetes.default:443?useServiceAccount=true&kubeletHttps=true&kubeletPort=10250&insecure=true -…

vim heapster-rbac.yaml …修改name部分 name: cluster-admin …

kubectl create -f heapster.yaml kubectl create -f heapster-rabc.yaml ```

  1. 界面如下:

K8s Dashboard - 图3

参考

博客园:基于kubernetes集群部署DashBoard
https://www.cnblogs.com/zhenyuyaodidiao/p/6500897.html