簡體   English   中英

如何使用 ingress 和 minikiube 訪問 kube.netes 儀表板

[英]How to access kubernetes dashboard with ingress and minikiube

我正在嘗試遵循使用 minikube 和入口公開 k8s 儀表板的教程。 基本上我所擁有的是以下入口藍圖:

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:

在我的host文件中,我添加了以下行:

192.168.49.2 dashboard.com

這就是我的host文件的樣子:

##
# 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

當我 curl dashboard.com我得到以下 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

我通常可以通過運行minikube dashboard來訪問儀表板。

我是 k8s 的新手。 如我所見,IP 地址 192.168.49.2 是外部 IP 地址。 將它添加到我的主機文件中無濟於事,因為它無論如何都不起作用。 (必須配置minikube tunnel,我試了好幾次,都不行)

我正在使用 Mac M1。

我的 docker 版本是: 20.10.21我的 minikube 版本是: 1.28.0我的 kubectl 版本是: 1.25.2

我錯過了什么?

因此,我通過關閉帶有隧道的終端並啟動一個新終端來做到這一點。 基本上對於 minikube,任何影響外部 IP 地址的新更改都必須啟動一個新隧道: minikube tunnel

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM