Search code examples
kubernetesvagrantvirtual-machinevirtualbox

Deploy Dashboard application to Kubernetes in vagrantbox (virtualbox)


I'm trying to setup a kubernetes cluster in virtualbox. I followed https://kubernetes.io/blog/2019/03/15/kubernetes-setup-using-ansible-and-vagrant and so far everything seems to work.

But I cannot get the dashboard application to work. I followed the guide from https://github.com/kubernetes/dashboard and https://github.com/kubernetes/dashboard/blob/master/docs/user/access-control/creating-sample-user.md but I cannot access the Web-UI from my host machine.

My whole setup can be found here: https://github.com/sebastian9486/v-kube-cluster/tree/feature/deploy-dashboard

My Vagrantfile is in src/main/kube-cluster and my ansible playbooks are in src/main/kube-cluster/kubernetes-setup. These parts so far work.

In src/main/kube-cluster/kubernetes-setup/deploy/ is the dashboard.sh to deploy the dashboard application. There may be some more elegant way, but for know I try to just get it running.

Installation looks okay. Output from my 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'

But I cannot access the page from my host machine.

List of pods from my master node kubectl get pods -A

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

Solution

  • The problem was resolved in the comments section but for better visibility I decided to provide an answer.

    After deploying Kubernetes Dashboard, to access it from a local workstation we can create a secure channel to Kubernetes cluster (proxy server between our machine and Kubernetes API server) by running:

    $ kubectl proxy
     Starting to serve on 127.0.0.1:8001
    

    NOTE: By default dashboard is only accessible from the machine that started proxy server.

    The dashboard endpoint will be accessible under following link:

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

    To learn about other ways of accessing Kubernetes Dashboard (kubectl port-forward, NodePort and Ingress), please visit the Accessing Dashboard documentation.