Docker 桌面上的 Kubernetes Ingress

Iac*_*hin 3 kubernetes docker-desktop

我正在尝试使用 Nginx ingress 访问本地电脑上的 kubernetes 仪表板。我遵循的步骤是:

获取 nginx 入口

kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v0.48.1/deploy/static/provider/cloud/deploy.yaml
Run Code Online (Sandbox Code Playgroud)

获取 kubernetes 仪表板

kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.2.0/aio/deploy/recommended.yaml
Run Code Online (Sandbox Code Playgroud)

应用此入口

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: dashboard-ingress
  namespace: kubernetes-dashboard
spec:
  rules:
  - host: "kubernetes.docker.internal"
    http:
      paths:
      - pathType: Prefix
        path: "/"
        backend:
          service:          
            name: kubernetes-dashboard
            port: 
              number: 443
Run Code Online (Sandbox Code Playgroud)

检查我的主机文件是否有这一行

127.0.0.1 kubernetes.docker.internal
Run Code Online (Sandbox Code Playgroud)

如果我尝试在浏览器上打开http://kubernetes.docker.internal/,我会收到“Http 错误 400 此页面无法正常工作”,而在邮递员上,我会收到错误 400,其中包含消息“客户端向HTTPS 服务器。”

我该如何解决?

Iac*_*hin 5

我解决了在 ingress yaml 中添加注释部分的问题。

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: dashboard-ingress
  namespace: kubernetes-dashboard
  annotations:
    kubernetes.io/ingress.class: "nginx"
    nginx.ingress.kubernetes.io/ssl-passthrough: "true"
    nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
spec:
  rules:
  - host: "kubernetes.docker.internal"
    http:
      paths:
      - pathType: Prefix
        path: "/"
        backend:
          service:          
            name: kubernetes-dashboard
            port: 
              number: 443
Run Code Online (Sandbox Code Playgroud)