简体   繁体   中英

How to access kubernetes dashboard with ingress and minikiube

I'm trying to follow a tutorial of exposing the k8s dashboard using minikube and ingress. Basically what I have is the following ingress blueprint:

apiVersion: v1
items:
- apiVersion: networking.k8s.io/v1
  kind: Ingress
  metadata:
    annotations:
      kubectl.kubernetes.io/last-applied-configuration: |
        {"apiVersion":"networking.k8s.io/v1","kind":"Ingress","metadata":{"annotations":{},"labels":{"name":"dashboard-ingress"},"name":"dashboard-ingress","namespace":"kubernetes-dashboard"},"spec":{"rules":[{"host":"dashboard.com","http":{"paths":[{"backend":{"service":{"name":"kubernetes-dashboard","port":{"number":80}}},"path":"/","pathType":"Prefix"}]}}]}}
    creationTimestamp: "2023-01-11T12:41:25Z"
    generation: 1
    labels:
      name: dashboard-ingress
    name: dashboard-ingress
    namespace: kubernetes-dashboard
    resourceVersion: "213743"
    uid: ffe793ff-b985-4560-84d3-981007f7f309
  spec:
    ingressClassName: nginx
    rules:
    - host: dashboard.com
      http:
        paths:
        - backend:
            service:
              name: kubernetes-dashboard
              port:
                number: 80
          path: /
          pathType: Prefix
  status:
    loadBalancer:
      ingress:
      - ip: 192.168.49.2
kind: List
metadata:

In my host file I have added the following line:

192.168.49.2 dashboard.com

That is how my host file looks like:

##
# 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
# 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
127.0.0.1 dashboard.com
# End of section

When I curl dashboard.com I get the following output:

*   Trying 127.0.0.1:80...
* connect to 127.0.0.1 port 80 failed: Connection refused
*   Trying 2606:4700:3032::6815:11fe:80...
* Connected to dashboard.com (2606:4700:3032::6815:11fe) port 80 (#0)
> GET / HTTP/1.1
> Host: dashboard.com
> User-Agent: curl/7.85.0
> Accept: */*
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 301 Moved Permanently
< Date: Wed, 11 Jan 2023 17:37:17 GMT
< Content-Type: text/html
< Transfer-Encoding: chunked
< Connection: keep-alive
< Location: http://www.dashboard.com/
< CF-Cache-Status: DYNAMIC
< Report-To: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=Fk%2F5iFEfMkDw1N8ej6xCnOz%2FvdhxnAz2Dg0NS8MtwjhopPZnCvJdt%2Fb6GNLtpB%2BK2TAVf11%2BYjCn4GSVQCWWhJvGlB97DE%2Bltvfn4TOSdNl1pKx0ev8I%2F3ik9HqCdXktIaAmYVzNhPyBw0%2Ba"}],"group":"cf-nel","max_age":604800}
< NEL: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
< Server: cloudflare
< CF-RAY: 787f6b60ce8a01b6-GRU
< alt-svc: h3=":443"; ma=86400, h3-29=":443"; ma=86400
< 
<html>
<head><title>301 Moved Permanently</title></head>
<body>
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx/1.22.0</center>
</body>
</html>
* Connection #0 to host dashboard.com left intact

I can normally access the dashboard by running minikube dashboard .

I'm new in k8s. As I can see, the IP address 192.168.49.2 is an external IP address. Adding it to my host file won't help I guess as it does not work anyway. (minikube tunnel has to be configured, I tried it several times, but it does not work)

I'm using Mac M1.

My docker version is: 20.10.21 My minikube version is: 1.28.0 My kubectl version is: 1.25.2

What am I missing?

So, I did it by closing my terminal with the tunnel and starting a new one. Basically with minikube, any new change that affects external IP addresses a new tunnel has to be started: minikube tunnel

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM