Posso acessar o painel do Kubernetes obtendo seu URL usando minikube dashboard --url
. No entanto, usando essa abordagem, um nome de porta diferente é usado sempre que reinicio o cluster Minikube. Portanto tento adicionar ingress-nginx
e expor o serviço 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.local
é mapeado para o endereço IP do endereço IP do cluster usando /etc/hosts
. Isso parece funcionar e o navegador está obtendo algum conteúdo inicial, mas a janela do navegador permanece vazia. Parece que apenas a solicitação inicial é roteada para o painel, mas as outras solicitações de recursos JS falham de alguma forma. O que há de errado com a regra de entrada?
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>
Registros do pod de entrada:
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
Não há nenhuma mensagem de log indicando que algo chegou ao pod kubernetes-dashboard
. Ao usar o URL de minikube dashboard --url
, posso ver os seguintes logs:
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}
...