¿Cómo utilizar Ingress para acceder al panel de kubernetes en Minikube?

¿Cómo utilizar Ingress para acceder al panel de kubernetes en Minikube?

Puedo acceder al tablero de kubernetes obteniendo su URL usando minikube dashboard --url. Sin embargo, al utilizar este enfoque, se utiliza un nombre de puerto diferente cada vez que reinicio el clúster Minikube. Por lo tanto, intento agregar ingress-nginxy exponer el servicio kubernetes-dashoard:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: k8s-dashboard-ingress
  namespace: kubernetes-dashboard
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
  rules:
  - host: kube-dashboard.local
    http:
      paths:
      - path: /
        pathType: Prefix  
        backend:
          service:
            name: kubernetes-dashboard
            port: 
              number: 80

kube-dashboard.localse asigna a la dirección IP de la dirección IP del clúster mediante /etc/hosts. Esto parece funcionar y el navegador obtiene contenido inicial, pero la ventana del navegador permanece vacía. Parece que solo la solicitud inicial se enruta al panel, pero las otras solicitudes de los recursos JS fallan de alguna manera. ¿Qué hay de malo con la regla de ingreso?

minikube kubectl -- describe service kubernetes-dashboard -n kubernetes-dashboard
Name:              kubernetes-dashboard
Namespace:         kubernetes-dashboard
Labels:            addonmanager.kubernetes.io/mode=Reconcile
                   k8s-app=kubernetes-dashboard
                   kubernetes.io/minikube-addons=dashboard
Annotations:       <none>
Selector:          k8s-app=kubernetes-dashboard
Type:              ClusterIP
IP Family Policy:  SingleStack
IP Families:       IPv4
IP:                10.105.10.141
IPs:               10.105.10.141
Port:              <unset>  80/TCP
TargetPort:        9090/TCP
Endpoints:         10.244.1.186:9090
Session Affinity:  None
Events:            <none>
minikube kubectl -- get ingress -n kubernetes-dashboard
NAME                    CLASS   HOSTS                  ADDRESS        PORTS   AGE
k8s-dashboard-ingress   nginx   kube-dashboard.local   192.168.58.2   80      11h
minikube kubectl -- describe ingress k8s-dashboard-ingress -n kubernetes-dashboard
Name:             k8s-dashboard-ingress
Labels:           <none>
Namespace:        kubernetes-dashboard
Address:          192.168.58.2
Ingress Class:    nginx
Default backend:  <default>
Rules:
  Host                  Path  Backends
  ----                  ----  --------
  kube-dashboard.local  
                        /   kubernetes-dashboard:80 (10.244.1.186:9090)
Annotations:            nginx.ingress.kubernetes.io/rewrite-target: /$1
Events:                 <none>

ingrese la descripción de la imagen aquí

Registros de pod de ingreso:

192.168.58.1 - - [12/Sep/2023:17:28:57 +0000] "GET / HTTP/1.1" 200 821 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/116.0" 364 0.002 [kubernetes-dashboard-kubernetes-dashboard-80] [] 10.244.1.186:9090 821 0.002 200 e71b7c14812998f8561b5175cc0f0b3a
192.168.58.1 - - [12/Sep/2023:17:28:57 +0000] "GET /runtime.134ad7745384bed8.js HTTP/1.1" 200 821 "http://kube-dashboard.local/" "Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/116.0" 318 0.002 [kubernetes-dashboard-kubernetes-dashboard-80] [] 10.244.1.186:9090 821 0.002 200 c55b47568d3dafe06b1a9ccaf18442d7
192.168.58.1 - - [12/Sep/2023:17:28:57 +0000] "GET /scripts.2c4f58d7c579cacb.js HTTP/1.1" 200 821 "http://kube-dashboard.local/" "Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/116.0" 318 0.003 [kubernetes-dashboard-kubernetes-dashboard-80] [] 10.244.1.186:9090 821 0.003 200 20d5cd52673bc584ff05f54feb76fa99
192.168.58.1 - - [12/Sep/2023:17:28:57 +0000] "GET /en.main.3550e3edca7d0ed8.js HTTP/1.1" 200 821 "http://kube-dashboard.local/" "Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/116.0" 318 0.004 [kubernetes-dashboard-kubernetes-dashboard-80] [] 10.244.1.186:9090 821 0.004 200 69b2b69e0fc4a406982c449cc661dd01
192.168.58.1 - - [12/Sep/2023:17:28:57 +0000] "GET /polyfills.5c84b93f78682d4f.js HTTP/1.1" 200 821 "http://kube-dashboard.local/" "Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/116.0" 320 0.005 [kubernetes-dashboard-kubernetes-dashboard-80] [] 10.244.1.186:9090 821 0.005 200 1614d55b9416bab79683a87254d8992d
192.168.58.1 - - [12/Sep/2023:17:28:57 +0000] "GET /assets/images/kubernetes-logo.png HTTP/1.1" 200 821 "http://kube-dashboard.local/" "Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/116.0" 346 0.002 [kubernetes-dashboard-kubernetes-dashboard-80] [] 10.244.1.186:9090 821 0.002 200 4414ae9d92778f8a2440829124251adc

No hay ningún mensaje de registro que indique que algo llega al pod kubernetes-dashboard. Cuando uso la URL de minikube dashboard --url, puedo ver los siguientes registros:

2023/09/12 17:34:08 [2023-09-12T17:34:08Z] Incoming HTTP/1.1 GET /api/v1/service/kubernetes-dashboard/kubernetes-dashboard/ingress?itemsPerPage=10&page=1&sortBy=d,creationTimestamp request from 127.0.0.1: 
2023/09/12 17:34:08 [2023-09-12T17:34:08Z] Incoming HTTP/1.1 GET /api/v1/service/kubernetes-dashboard/kubernetes-dashboard/event?itemsPerPage=10&page=1&sortBy=d,lastSeen request from 127.0.0.1: 
2023/09/12 17:34:08 [2023-09-12T17:34:08Z] Incoming HTTP/1.1 GET /api/v1/service/kubernetes-dashboard/kubernetes-dashboard request from 127.0.0.1: 
2023/09/12 17:34:08 Getting details of kubernetes-dashboard service in kubernetes-dashboard namespace
2023/09/12 17:34:08 [2023-09-12T17:34:08Z] Incoming HTTP/1.1 GET /api/v1/namespace request from 127.0.0.1: 
2023/09/12 17:34:08 Getting list of namespaces
2023/09/12 17:34:08 [2023-09-12T17:34:08Z] Incoming HTTP/1.1 GET /api/v1/service/kubernetes-dashboard/kubernetes-dashboard/pod?itemsPerPage=10&page=1&sortBy=d,creationTimestamp request from 127.0.0.1: 
2023/09/12 17:34:08 Found 0 events related to kubernetes-dashboard service in kubernetes-dashboard namespace
2023/09/12 17:34:08 Found 1 endpoints related to kubernetes-dashboard service in kubernetes-dashboard namespace
2023/09/12 17:34:08 [2023-09-12T17:34:08Z] Outcoming response to 127.0.0.1 with 200 status code
2023/09/12 17:34:08 [2023-09-12T17:34:08Z] Outcoming response to 127.0.0.1 with 200 status code
2023/09/12 17:34:08 [2023-09-12T17:34:08Z] Outcoming response to 127.0.0.1 with 200 status code
2023/09/12 17:34:08 [2023-09-12T17:34:08Z] Outcoming response to 127.0.0.1 with 200 status code
2023/09/12 17:34:08 Getting pod metrics
2023/09/12 17:34:08 [2023-09-12T17:34:08Z] Outcoming response to 127.0.0.1 with 200 status code
2023/09/12 17:34:11 Getting application global configuration
2023/09/12 17:34:11 Application configuration {"serverTime":1694540051060}
...

información relacionada