Kubernetes:从远程浏览器访问仪表板 [英] Kubernetes : Access dashboard from remote browser

查看:160
本文介绍了Kubernetes:从远程浏览器访问仪表板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个已经建立的小型Kubernetes集群(主要是)

I have a small Kubernetes cluster that I have built following (mostly) this tuto.

因此,我在Virtual Box CentOS VM上有一个主服务器和一些从属服务器,我想从主机上的浏览器访问Kubernetes仪表板.

So I have a master and some slaves on Virtual Box CentOS VMs, and I want to access the Kubernetes dashboard from a browser on my host machine.

所以我使用了此文件创建我的仪表板服务,部署,角色绑定等.并按如下所示启动代理:

So I used this file to create my dashboard service, deployment, role binding, ... . And started a proxy as follow :

 kubectl proxy --port=9999 --address=[MASTER_IP_ADDRESS] --accept-hosts="^*$"

然后我尝试使用URL:http://[MASTER_IP_ADDRESS]:9999/api/v1/namespaces/kube-system/services/kubernetes-dashboard从浏览器访问仪表板,但显示了以下json:

I then tried to access the dashboard from my browser using the URL : http://[MASTER_IP_ADDRESS]:9999/api/v1/namespaces/kube-system/services/kubernetes-dashboard, but I get the following json displayed :

{
"kind": "Service",
  "apiVersion": "v1",
  "metadata": {
    "name": "kubernetes-dashboard",
    "namespace": "kube-system",
    "selfLink": "/api/v1/namespaces/kube-system/services/kubernetes-dashboard",
    "uid": "a0b1d1bc-5adf-11e9-a89e-080027cef83a",
    "resourceVersion": "569",
    "creationTimestamp": "2019-04-09T15:53:33Z",
    "labels": {
      "k8s-app": "kubernetes-dashboard"
    },
    "annotations": {
      "kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"v1\",\"kind\":\"Service\",\"metadata\":{\"annotations\":{},\"labels\":{\"k8s-app\":\"kubernetes-dashboard\"},\"name\":\"kubernetes-dashboard\",\"namespace\":\"kube-system\"},\"spec\":{\"ports\":[{\"port\":443,\"targetPort\":8443}],\"selector\":{\"k8s-app\":\"kubernetes-dashboard\"}}}\n"
    }
  },
  "spec": {
    "ports": [
      {
        "protocol": "TCP",
        "port": 443,
        "targetPort": 8443
      }
    ],
    "selector": {
      "k8s-app": "kubernetes-dashboard"
    },
    "clusterIP": "10.102.168.28",
    "type": "ClusterIP",
    "sessionAffinity": "None"
  },
  "status": {
    "loadBalancer": {

    }
  }
}

如何访问仪表板?

注意:

  • 浏览URL http://192.168.99.20:9999/api/v1/namespaces/kube-system/services/kubernetes-dashboard:/proxy时,出现503 no endpoints available for service \"kubernetes-dashboard\"错误.
  • When I browse the URL http://192.168.99.20:9999/api/v1/namespaces/kube-system/services/kubernetes-dashboard:/proxy, I get a 503 no endpoints available for service \"kubernetes-dashboard\" error.

经过深入研究,我认为问题不仅仅在于我无法访问仪表板".我用所有您可以在这里找到.

After some digging up, I think that the problem is deeper thant just 'I can't access the dashboard'. I created another question with all the informations that you can find here.

推荐答案

通过kubectl代理访问Kubernetes仪表板

To access Kubernetes dashboard through kubectl proxy

  1. 确认您的kubernetes仪表板正在运行并且准备就绪

例如 kubectl -n kube-system get pods | grep dashboard

  1. 按照官方说明访问仪表板:

  • 例如kubectl proxy(默认为8001)

    • e.g. kubectl proxy (proxies to 8001) by default

      访问仪表板

      http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/

      http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/

      只能从执行命令的计算机上访问UI.有关更多选项,请参见kubectl代理--help.

      The UI can only be accessed from the machine where the command is executed. See kubectl proxy --help for more options.

      https://kubernetes.io/docs/任务/访问应用程序集群/web-ui-dashboard/

      这篇关于Kubernetes:从远程浏览器访问仪表板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆