Home > Blockchain >  Minikube: Kubernetes Ingress not reachabled / loads forever
Minikube: Kubernetes Ingress not reachabled / loads forever

Time:01-11

I want to create an ingress for the kubernetes dashboard, but it loads forever inside the browser: Mac

minikube start --driver=docker
minikube addons enable ingress
minikube addons enable ingress-dns
minikube addons enable dashboard
minikube addons enable metrics-server
❯ kubectl get ns
NAME                   STATUS   AGE
default                Active   4m13s
ingress-nginx          Active   109s
kube-node-lease        Active   4m14s
kube-public            Active   4m14s
kube-system            Active   4m14s
kubernetes-dashboard   Active   51s

❯ kubectl get service -n kubernetes-dashboard
NAME                        TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)    AGE
dashboard-metrics-scraper   ClusterIP   10.105.2.220     <none>        8000/TCP   82s
kubernetes-dashboard        ClusterIP   10.106.101.254   <none>        80/TCP     82s
// dashboard-ingress.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: dashboard-ingress
  namespace: kubernetes-dashboard
  annotations:
    kubernetes.io/ingress.class: "nginx"
spec:
  rules:
  - host: dashboard.com
    http:
      paths:
      - path: /
        pathType: Exact  
        backend:
          service:
            name: kubernetes-dashboard
            port: 
              number: 80
❯ kubectl apply -f dashboard-ingress.yaml
ingress.networking.k8s.io/dashboard-ingress created
❯ kubectl get ingress -n kubernetes-dashboard
NAME                CLASS    HOSTS           ADDRESS        PORTS   AGE
dashboard-ingress   <none>   dashboard.com   192.168.49.2   80      67s
// etc/hosts
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1       localhost
255.255.255.255 broadcasthost
::1             localhost
192.168.49.2    dashboard.com
# Added by Docker Desktop
# To allow the same kube context to work on the host and the container:
127.0.0.1 kubernetes.docker.internal
# End of section
~                    

When I now try to load dashboard.com or also 192.168.49.2 in the browser, it just loads forever and does nothing. When i try to load http://127.0.0.1/ I get a nginx 404

Am I missing something?

CodePudding user response:

The ingress addon is currently not fully supported on docker driver on MacOs (due the limitation on docker bridge on mac) you need to use minikube tunnel command. Minikube docs - Known isses, GitHub issue

Enabling the ingress addon on Mac shows that the ingress will be available on 127.0.0.1. Support Ingress on MacOS, driver docker

So you only need to add the following line to your /etc/hosts file.

127.0.0.1  dashboard.com

Create tunnel (it will ask your sudo password)

minikube tunnel

Then you can verify that the Ingress controller is directing traffic:

curl dashboard.com

(also I used this Ingress)

kubectl apply -f - << EOF
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: dashboard-ingress
  namespace: kubernetes-dashboard
spec:
  rules:
  - host: dashboard.com
    http:
      paths:
        - pathType: Prefix
          path: "/"
          backend:
            service:
              name: kubernetes-dashboard
              port:
                number: 80    
EOF
  • Related