Search code examples
kubernetesdebiankubernetes-ingressnginx-ingress

Kubernetes Dashboard - Exposing with Ingress-Nginx


i am new to the whole Kubernetes community and i am currently trying to get a dashboard exposed with Ingress-Nginx. I've tried several things but i am unnable to find a good explaination on how to expose the dashboard with Ingress. All i've got now is a Dashboard that is accessible through 'kubectl port-forward'. I also have Ingress-Nginx installed and the controller is running. How should i start to create an Ingress for the kubernetes dashboard?


Solution

  • For a bare-metal environment like yours, Nginx-Ingress alone is not enough, because you are missing a load balancer which usually is automatically provided on public clouds like AWS, Google Cloud, etc.

    To expose services through ingress resource in a bare metal environment, you have two options.

    NodePort

    A service with NodePort is exposed on every node of your Kubernetes cluster at a static port. To do this just edit your kubernetes-dashboard service (be aware that naming could change depending on how you installed Kubernetes dashboard):

    kubectl -n kubernetes-dashboard edit service kubernetes-dashboard
    

    and change type: ClusterIP to type: NodePort. After doing this, check again your service:

    kubectl -n kubernetes-dashboard get svc kubernetes-dashboard
    
    NAME                   TYPE       CLUSTER-IP      EXTERNAL-IP   PORT(S)         AGE
    kubernetes-dashboard   NodePort   10.43.120.193   <none>        443:31120/TCP   9m7s
    

    If you look at PORT(S) output, you will see that a random port was exposed (in my example 31120). To access your dashboard now you only need to use:

    https://node-ip:31120

    MetalLB

    This is a much cooler solution, because it will allow you to use services of type LoadBalancer, like if you were on a public cloud provider. This requires some basic network knowledge, but it's very easy to use and very flexible for testing environments. You can find more information on MetalLB website.

    Here also couple of useful links to understand better the concepts I explained above.

    Nginx-Ingress - Bare-metal considerations

    Kubernetes Services