Search code examples
kubernetesremote-serverubuntu-servermicrok8skubernetes-dashboard

How can I acces the Kubernetes Dashboard on a remote Machine


I am new at kubernetes and I am trying to setup a clsuter on a remote server. For this I use microk8s and a server from hetzner-cloud (https://www.hetzner.com/de/cloud).

I entered the server with ssh and followd the microk8s installation instructions for linux(https://microk8s.io/). That all seemed to work fine. My problem is now that I have not found a way to access the kubernetes-dashboard.

I've tryed the workaround with NodePort and microk8s kubectl proxy --disable-filter = true but it does not work and is not recommended for security reasons. With the disable Filter Method it is possible to access the login page but it does not respond.

I've also tryed to access the dashbourd from outside using a ssh tunnel and this tutorial: How can I remotely access kubernetes dashboard with token

The tunnel seems to works fine, but I still cannot access the port.

Now I have two main questions:

1: How do you usualy use kubernetes, if kubernetes does not wan you to access the dashboard from outside. Because don't you run your services usualy on a rented server that is not in you living room? What's the point I simply do not get?

2: How can I access the Dashborad?

I would be really happy, if anybody could help me. I am already struggling with this problem since a month now. :)

best greetings, mamo


Solution

  • In order to access the K8s services from outside using HTTP, you should configure and use ingress controller.

    after ingress is running, you will be able to specify a "path" or route and a port and name that points to your service.

    Once this is done, you should be able to access the dashboard

    Sample configuration (reference)

    ---
    apiVersion: extensions/v1beta1
    kind: Ingress
    metadata:
      name: dashboard-google
      namespace: kube-system
      annotations:
        nginx.ingress.kubernetes.io/secure-backends: "true"
        nginx.ingress.kubernetes.io/ssl-passthrough: "true"
    spec:
      tls:
        - hosts:
          - kube.mydomain.com
          secretName: tls-secret
      rules:
        - host: kube.mydomain.com
          http:
            paths:
            - path: /
              backend:
                serviceName: kubernetes-dashboard
                servicePort: 443