将Dashboard应用程序部署到vagrantbox (virtualbox)中的Kubernetes



我正在尝试在virtualbox中设置kubernetes集群。我跟随https://kubernetes.io/blog/2019/03/15/kubernetes-setup-using-ansible-and-vagrant,到目前为止,一切似乎都工作。

但是我不能让仪表板应用程序工作。我遵循了https://github.com/kubernetes/dashboard和https://github.com/kubernetes/dashboard/blob/master/docs/user/access-control/creating-sample-user.md的指南,但我无法从主机访问Web-UI。

我的整个设置可以在这里找到:https://github.com/sebastian9486/v-kube-cluster/tree/feature/deploy-dashboard

我的Vagrantfile在src/main/kube-cluster,我的可见剧本在src/main/kube-cluster/kubernetes-setup。到目前为止,这些部分都可以工作。

在src/main/kube-cluster/kubernetes-setup/deploy/中是dashboard.sh,用于部署dashboard应用程序。可能有一些更优雅的方法,但是我尽量让它运行。

安装正常。我的dashboard.sh的输出

[INFO] Deploy and configure application 'dashboard'
[INFO] Start deployment
namespace/kubernetes-dashboard created
serviceaccount/kubernetes-dashboard created
service/kubernetes-dashboard created
secret/kubernetes-dashboard-certs created
secret/kubernetes-dashboard-csrf created
secret/kubernetes-dashboard-key-holder created
configmap/kubernetes-dashboard-settings created
role.rbac.authorization.k8s.io/kubernetes-dashboard created
clusterrole.rbac.authorization.k8s.io/kubernetes-dashboard created
rolebinding.rbac.authorization.k8s.io/kubernetes-dashboard created
clusterrolebinding.rbac.authorization.k8s.io/kubernetes-dashboard created
deployment.apps/kubernetes-dashboard created
service/dashboard-metrics-scraper created
deployment.apps/dashboard-metrics-scraper created
Connection to 127.0.0.1 closed.
Connection to 127.0.0.1 closed.
[DONE] Finished deployment
[INFO] Start configuration
serviceaccount/admin-user created
Connection to 127.0.0.1 closed.
clusterrolebinding.rbac.authorization.k8s.io/admin-user created
Connection to 127.0.0.1 closed.
[INFO] ******************************************************************
[INFO] ***** BEARER TOKEN ***********************************************
eyJhbGciOiJSUzI1NiIsImtpZCI6IlRzWkFqejB1RnJJUjBNUDlXSHo0MEVBZmRlTFN1MmxYRThweFRBVTdRNmsifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlcm5ldGVzLWRhc2hib2FyZCIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJhZG1pbi11c2VyLXRva2VuLWxjajQ4Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQubmFtZSI6ImFkbWluLXVzZXIiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC51aWQiOiIwYzhiMjFiYS05ZWZkLTRmNjUtOGM5Yi0wZTczMGU3NGUyZTUiLCJzdWIiOiJzeXN0ZW06c2VydmljZWFjY291bnQ6a3ViZXJuZXRlcy1kYXNoYm9hcmQ6YWRtaW4tdXNlciJ9.LExiVLOykdGVmtXNyUz2vn0VPc1Gazlng-lKnnBV541XPRjUjudjAaTKvfVoOQfEUDxLTLCLS8ePNPqXpnF3zvf7NEmBV5KCttCQWyqFW5PoiQVF2MbFiIXGMHYfYoBrjw_-BqKtbUAr23akPIp8n0m9OyQrHSbGz4m6T1kt2NwcKAX-rpIvkcLo5SaxFpMb6om-pce2EUjQ8fy17ciskN988_jhTgfXQEuwCuIIoUQ_ZblY1MABtdKE0STt9M78qzkY2sZQv8yeKzpmsWSrpX0CechFlA6Ce1XaWrwbqt6vSYpejuK34j1aWh4cUG-f50LaPwXZUnQhbLRViSZaYQConnection to 127.0.0.1 closed.
[INFO] ******************************************************************
[INFO] ******************************************************************
[DONE] Finished configuration
[INFO] Finished Deployment and configuration of application 'dashboard'

但是我无法从主机访问该页。

主节点kubectl get pods -A的pod列表

NAMESPACE              NAME                                         READY   STATUS    RESTARTS   AGE
kube-system            calico-kube-controllers-86bddfcff-dl6hl      1/1     Running   0          5m49s
kube-system            calico-node-gvjqp                            1/1     Running   0          2m15s
kube-system            calico-node-jsvk6                            1/1     Running   0          5m50s
kube-system            coredns-74ff55c5b-nhkwv                      1/1     Running   0          5m49s
kube-system            coredns-74ff55c5b-pjl97                      1/1     Running   0          5m49s
kube-system            etcd-v-k8s-master                            1/1     Running   0          5m58s
kube-system            kube-apiserver-v-k8s-master                  1/1     Running   0          5m58s
kube-system            kube-controller-manager-v-k8s-master         1/1     Running   0          5m58s
kube-system            kube-proxy-cb79j                             1/1     Running   0          2m15s
kube-system            kube-proxy-vq7lr                             1/1     Running   0          5m50s
kube-system            kube-scheduler-v-k8s-master                  1/1     Running   0          5m58s
kubernetes-dashboard   dashboard-metrics-scraper-79c5968bdc-jc7hl   1/1     Running   0          2m11s
kubernetes-dashboard   kubernetes-dashboard-7448ffc97b-czsdn        1/1     Running   0          2m11s

这个问题已经在评论区解决了,但为了更好地看到,我决定提供一个答案。

部署Kubernetes Dashboard后,要从本地工作站访问它,我们可以通过运行以下命令创建一个通往Kubernetes集群(我们的机器和Kubernetes API服务器之间的代理服务器)的安全通道:

$ kubectl proxy
Starting to serve on 127.0.0.1:8001

注意:默认情况下,仪表板只能从启动代理服务器的机器访问。

仪表板端点将在以下链接下访问:

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

了解访问Kubernetes Dashboard的其他方法(kubectl port-forward, NodePort和Ingress),请访问访问Dashboard文档。

相关内容

  • 没有找到相关文章

最新更新