美文网首页
Mac上使用Docker Desktop安装dashboard

Mac上使用Docker Desktop安装dashboard

作者: 中v中 | 来源:发表于2020-08-13 15:00 被阅读0次

    3 安装Dashboard

    Dashboard并不是必须的,它可以方便我们查看和操作,建议还是安装。将文件下载到本地,然后执行以下命令即可:

    // 下载
    wget https://raw.githubusercontent.com/kubernetes/dashboard/v1.10.1/src/deploy/recommended/kubernetes-dashboard.yaml
    
    // 执行
    kubectl apply -f kubernetes-dashboard.yaml
    结果如下,表示ok
    secret/kubernetes-dashboard-certs created
    serviceaccount/kubernetes-dashboard created
    role.rbac.authorization.k8s.io/kubernetes-dashboard-minimal created
    rolebinding.rbac.authorization.k8s.io/kubernetes-dashboard-minimal created
    deployment.apps/kubernetes-dashboard created
    service/kubernetes-dashboard created
    

    服务安装完毕后可以查看部署的容器与服务:
    出现 kubernetes-dashboard 1/1 则表示正常

    ➜  kubernetes  kubectl get deployments --namespace kube-system
    NAME                   READY   UP-TO-DATE   AVAILABLE   AGE
    coredns                2/2     2            2           4d3h
    kubernetes-dashboard   1/1     1            1           3d8h
    ➜  kubernetes  kubectl get services --namespace kube-system
    NAME                   TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)                  AGE
    kube-dns               ClusterIP   10.96.0.10      <none>        53/UDP,53/TCP,9153/TCP   4d3h
    kubernetes-dashboard   ClusterIP   10.96.229.197   <none>        443/TCP                  4d2h
    

    启动:

    $ kubectl proxy
    

    建议使用下面命令启动,不然会一直占着终端:

    $ nohup kubectl proxy >/dev/null &
    

    启动后可登陆访问:http://localhost:8001/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/

    获取Token

    然后并没有跳过的按钮,所以必须通过Kubeconfig或者Token的方式。

    我这里是通过Token,那我们怎么知道Token的值是多少呢?

    ➜  kubernetes  kubectl get secret -n=kube-system
    NAME                                             TYPE                                  DATA   AGE
    ...
    default-token-sznp4                              kubernetes.io/service-account-token   3      4d3h
    ...
    # 这里只列出default-token-sznp4
    

    获取Token值,然后把得到的值输入进去就可以了。

    ➜  kubernetes  kubectl describe secret -n=kube-system default-token-sznp4
    Name:         default-token-sznp4
    Namespace:    kube-system
    Labels:       <none>
    Annotations:  kubernetes.io/service-account.name: default
                  kubernetes.io/service-account.uid: 064afefb-ebf6-11e9-ac8c-025000000001
    
    Type:  kubernetes.io/service-account-token
    
    Data
    ====
    ca.crt:     1025 bytes
    namespace:  11 bytes
    token:      eyJhbGciOiJSUzI1NiIsImtpZCI6IiJ9.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlLXN5c3RlbSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJkZWZhdWx0LXRva2VuLXN6bnA0Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQubmFtZSI6ImRlZmF1bHQiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC51aWQiOiIwNjRhZmVmYi1lYmY2LTExZTktYWM4Yy0wMjUwMDAwMDAwMDEiLCJzdWIiOiJzeXN0ZW06c2VydmljZWFjY291bnQ6a3ViZS1zeXN0ZW06ZGVmYXVsdCJ9.u5HTqt7A_4H_0f9ny-AgfmWNo7TSWZsRpjXot1iN8G6oOnt4uDQiS_kiUduwtqqeYC2hjZ2yKPt0NNML9Op1RSAEuTkXiRvJxnCX8GjQeqCD4lzXeqqQ9mTxCVlGijJLaP5VJ2qQtLM0Gwt9eJCYxugGqqHqys7QXdPzcH3WESno0tXNt25klC5ZXNFSeyE-AqLpP3SjmW7W6IBHx89uY28SXmdvTjnCuZyaBlpkgOensdMS7-BpycTzq63NIcp5TR7tM3AdHjsUlSJ2D9YqW_xzMcEDncmjKpbVJ6W9w494L-Z0dOjHkI7gaQSE2Bwi6AqCaGEWKTgMCSWmIBfkrg
    

    注意: 这个是dashboard旧版本v1 的配置方案,对于k8s v1.16以上不好用,需要用到dashboard v2了。

    相关文章

      网友评论

          本文标题:Mac上使用Docker Desktop安装dashboard

          本文链接:https://www.haomeiwen.com/subject/atgbdktx.html