美文网首页
k8s官方文档实践系统-访问Dashboard的三种方式

k8s官方文档实践系统-访问Dashboard的三种方式

作者: JerryAi | 来源:发表于2019-08-01 23:47 被阅读0次

    方式一 NodePort

    This way of accessing Dashboard is only recommended for development environments in a single node setup.

    这种访问Dashboard的方法,推荐仅用于单个节点的开发环境。

    使用如下命令编辑service

    $ kubectl -n kube-system edit service kubernetes-dashboard
    

    该使命与vim命令类似,替换响应内容中的 type: ClusterIPtype: NodePort ,保存即可。

    Next we need to check port on which Dashboard was exposed.
    接下来找出Dashboard暴露的端口

    $ kubectl -n kube-system get service kubernetes-dashboard
    NAME                   CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE
    kubernetes-dashboard   10.100.124.90   <nodes>       443:31707/TCP   21h
    

    Dashboard has been exposed on port 31707 (HTTPS). Now you can access it from your browser at: https://<master-ip>:31707. master-ip can be found by executing kubectl cluster-info. Usually it is either 127.0.0.1 or IP of your machine, assuming that your cluster is running directly on the machine, on which these commands are executed.

    In case you are trying to expose Dashboard using NodePort on a multi-node cluster, then you have to find out IP of the node on which Dashboard is running to access it. Instead of accessing https://<master-ip>:<nodePort> you should access https://<node-ip>:<nodePort>.

    方式二 Kubernetes API server

    In case Kubernetes API server is exposed and accessible from outside you can directly access dashboard at: https://<master-ip>:<apiserver-port>/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/

    Note: This way of accessing Dashboard is only possible if you choose to install your user certificates in the browser. In example certificates used by kubeconfig file to contact API Server can be used.

    生成crt文件

    grep 'client-certificate-data' /etc/kubernetes/admin.conf \
    | head -n 1 \
    | awk '{print $2}' \
    | base64 -d \
    >> kubecfg.crt
    

    生成key文件

    grep 'client-key-data' /etc/kubernetes/admin.conf \
    | head -n 1 \
    | awk '{print $2}' \
    | base64 -d \
    >> kubecfg.key
    

    生成p12证书文件(证书的生成和导入需要一个密码)

    openssl pkcs12 \
    -export \
    -clcerts \
    -inkey kubecfg.key \
    -in kubecfg.crt \
    -out kubecfg.p12 \
    -name "kubernetes-client"
    

    https://<master-ip>:<apiserver-port>/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/

    方式三 Ingress

    Dashboard can be also exposed using Ingress resource. For more information check: https://kubernetes.io/docs/concepts/services-networking/ingress.

    相关文章

      网友评论

          本文标题:k8s官方文档实践系统-访问Dashboard的三种方式

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