如何使用命令 helm create 设置 nginx ingress?

How to set nginx ingress with command helm create?

我无法让我的 ingress 在本地工作 docker-desktop

我做了一个helm create my-project-helm和大家一样

然后我会在 ./my-project-helm/values.yaml 中进行更改 我只向您展示最有趣的部分(关于入口)

...

replicaCount: 3

image:
  repository: localhost:5000/my-project-helm
  tag: latest
  pullPolicy: IfNotPresent

...

service:
  type: ClusterIP
  port: 80

ingress:
  enabled: true
  annotations: {
    kubernetes.io/ingress.class: nginx
  }
    # kubernetes.io/ingress.class: nginx
    # kubernetes.io/tls-acme: "true"
  hosts:
    - host: chart-example.local
      paths: [/]

...

我安装了这个头盔helm upgrade --install my-project-helm ./my-project-helm

我安装nginxhelm upgrade --install nginx-ingress stable/nginx-ingress

我要用 kubectl describe ingress my-project-helm

检查我的入口
Name:             my-project-helm
Namespace:        default
Address:          
Default backend:  default-http-backend:80 (<none>)
Rules:
  Host                 Path  Backends
  ----                 ----  --------
  chart-example.local  /     my-project-helm:80 (10.1.0.71:80,10.1.0.72:80,10.1.0.73:80)
Annotations:
  kubernetes.io/ingress.class:  nginx
Events:
  Type    Reason  Age   From                      Message
  ----    ------  ----  ----                      -------
  Normal  CREATE  14m   nginx-ingress-controller  Ingress default/my-project-helm
  Normal  UPDATE  13m   nginx-ingress-controller  Ingress default/my-project-helm

一切都显得那么美好。

我做了一个curl chart-example.local什么都没发生curl: (6) Could not resolve host: chart-example.local

有人知道吗?

默认情况下,它应该在您的 /etc/hosts

中添加 Kubernetes master

kubectl cluster-info

检查一下

所以只需使用我的默认域 kubernetes.docker.internal 而不是 chart-example.local

是的,它必须指向 nginx 的负载均衡器外部 IP,默认情况下是 localhost ;)