DevOpsHow Tokubernetes

How to Setup Ingress on Minikube Kubernetes with example

If you are learning Kubernetes then you might had heard of Ingress object which is used to allow external network access to the Kubernetes cluster. For doing a hands on, Minikube is one of the widely used software which setups Kubernetes environment. In this article, I am going to show you how to enable Ingress in Minikube and a example on how to use it.

Before You Begin

If you are new to Minikube and haven't installed it yet, then refer to the below article for the installation steps.

  • Install Kubernetes using Minikube on Linux, CentOS, Fedora, Red Hat

You should have a working Minikube setup and dashboard. The kubectl tool must be installed and working in tandem with Minikube.

Start Minikube

minkube start

Enable Ingress Controller

  • Run the following command to enable the NGINX Ingress controller:
minikube addons enable ingress
  • Verify whether Ingress controller is running or not:
kubectl get pods -n kube-system

Use Kubernetes Dashboard as application

Since Ingress controller is enabled and ready for use, lets deploy Ingress service for Minikube Kubernetes dashboard.

  • Get the Kubernetes dashboard details which is present in kubernetes-dashboard namespace by running following command:
kubectl get all -n kubernetes-dashboard


NAME                                             READY   STATUS    RESTARTS   AGE
pod/dashboard-metrics-scraper-7976b667d4-f6q74   1/1     Running   6          23d
pod/kubernetes-dashboard-6fcdf4f6d-ghq97         1/1     Running   12         23d

NAME                                TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)    AGE
service/dashboard-metrics-scraper   ClusterIP      <none>        8000/TCP   23d
service/kubernetes-dashboard        ClusterIP   <none>        80/TCP     23d

NAME                                        READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/dashboard-metrics-scraper   1/1     1            1           23d
deployment.apps/kubernetes-dashboard        1/1     1            1           23d

NAME                                                   DESIRED   CURRENT   READY   AGE
replicaset.apps/dashboard-metrics-scraper-7976b667d4   1         1         1       23d
replicaset.apps/kubernetes-dashboard-6fcdf4f6d         1         1         1       23d
  • Note down the Kubernetes dashboard service name and port (highlighted in above output) which will be used to create ingress resource.

Create Ingress Resource and Validate

  • Let's create a ingress resource using dashboard-ingress.yaml file with below contents:
kind: Ingress
  name: dashboard-ingress
  namespace: kubernetes-dashboard
      - host:
          - path: /
            pathType: Prefix
                name: kubernetes-dashboard
                  number: 80
  • In the above file, apiVersion  and kind denotes ingress resource.
  • The name of the resource will be dashboard-ingress which will be created under kubernetes-dashboard namespace. Note that we are not using default namespace here because kubernetes-dashboard is present in kubernetes-dashboard namespace.
  • Under specification we define host name as as an example here. You can use any domain here as we will be creating host file entry later. Under http, provide path to which dashboard opens, service name to use and port number on which service is exposed. If you recollect, this information is already gathered in previous step.
  • Let's create ingress resource using the above file now by running following command:
kubectl apply -f dashboard-ingress.yaml

Output: created
  • Get the ingress resource details like IP and port by running following command:
kubectl get ingress -n kubernetes-dashboard


NAME                CLASS    HOSTS               ADDRESS          PORTS   AGE
dashboard-ingress   <none>   80      3m53s
  • We have specified domain name in ingress resource file. Let's create a local host file entry on system and point it to the IP which is assigned by ingress service as in above output.
  • After adding the entry, browse the domain and you should see the kubernetes dashboard displayed as in following image:


Do you have any additional comments, questions, or concerns you would like to share? Please post in comments section.

Abhijit Sandhan

Love to Automate, Blog, Travel, Hike & spread Knowledge!

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Back to top button