美文网首页
kubernetes启动dashboard

kubernetes启动dashboard

作者: rekca | 来源:发表于2020-12-27 19:16 被阅读0次

    搭建k8s环境见:https://www.jianshu.com/p/9d8147f2952d

    1. 从github下载dashboard yaml文件

    从kubernetes/kubernetes仓库的下载

    kubernetes/cluster/addons/dashboard/dashboard.yaml

    ,dashboard默认暴露的是cluster ip,如果我们想要在集群外面的集群上访问dashboard的话,就访问不了,修改dashboard.yaml的dashboard的service配置即可,如下:

    kind: Service
    apiVersion: v1
    metadata:
      labels:
        k8s-app: kubernetes-dashboard
        kubernetes.io/cluster-service: "true"
        addonmanager.kubernetes.io/mode: Reconcile
      name: kubernetes-dashboard
      namespace: kubernetes-dashboard
    spec:
      ports:
        - port: 443
          targetPort: 8443
      selector:
        k8s-app: kubernetes-dashboard
      type: NodePort # 增加type字段为NodePort即可
    

    2. 部署dashboard

    kubectl apply -f dashboard.yaml
    

    3. 配置dashboard

    kubectl create serviceaccount dashboard-view -n kubernetes-dashboard # 创建sa
    kubectl create clusterrolebinding dashboard-view --clusterrole=view --serviceaccount=dashboard-view # 创建clusterrolebingding
    kubectl describe secrets -n kubernetes-dashboard $(kubectl -n kubernetes-dashboard  get secret | awk '/dashboard-view/{print $1}') # 获取secrets的token
    

    如下:eyJhbGciOiJSUzI1NiIsImtpZCI6InhuTFE2WmtqZFowNkhibzN4cDM5WHlWRVhLNHJvaWRTckh4SlkxcjZXMm8ifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlcm5ldGVzLWRhc2hib2FyZCIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJkYXNoYm9hcmQtdmlldy10b2tlbi1zZzhubiIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50Lm5hbWUiOiJkYXNoYm9hcmQtdmlldyIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50LnVpZCI6IjEwN2Y0OGY0LWM2YmUtNGRmMy1iYjM2LWQ4ZjM4YzI0Y2UzNyIsInN1YiI6InN5c3RlbTpzZXJ2aWNlYWNjb3VudDprdWJlcm5ldGVzLWRhc2hib2FyZDpkYXNoYm9hcmQtdmlldyJ9.Y0q4XV9XgtpQ-A9U-x9VjhTaNNosBCExmXpczNn4ZFLUs_MmYSnX3JIeOQHmpP-hIJla2b3McbiXFwZc7rmP6DT48YexT6Jcnkdyv_IuBEE9B0ZLME3PusIj1Vc0uJsorOrbsfDpIwHBGPerUEnE05hBTVgN5DNi8VWMH5FnlEvqcUjYBmOymqFTOGvwNNdexE85yWvfZokBttt4Q6CRRWPaYDJ-YP4ff1petJ6QH5O2apHdAbeKaZl5zo4WZnOClgC-45vi_owCkF6E9SCBRlrdkivrUc1WujpdVDjJe-nz4DrbkTMURJIBneBRB2KcnEAxMeDRyoFWW9Vh7Jba_g

    4. 登录dashboard

    kubectl get svc -n kubernetes-dashboard # 获取创建的svc
    
    image.png

    如图:用集群里任意一台node的ip地址加31786端口就可以访问dashboard了


    image.png

    选择token登录,输入上面获取到的token


    image.png

    相关文章

      网友评论

          本文标题:kubernetes启动dashboard

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