Ingress 使用通配符,虽然我没有指定

Ingress uses wildcard, although I didn't specify that

我有以下入口:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: my-ingress
  namespace: apps
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/custom-http-errors: '404'
spec:
  tls:
    - hosts:
        - mywebsite.com
      secretName: my-secret-tls
  rules:
  - host: mywebsite.com
  - http:
      paths:
        - path: /api/events
          pathType: ImplementationSpecific
          backend:
            service:
              name: my-events-api-svc
              port:
                number: 80

当我kubectl describe这个入口时,我看到以下

Name:             my-ingress
Namespace:        apps
Address:          52.206.112.10
Default backend:  default-http-backend:80 (<error: endpoints "default-http-backend" not found>)
TLS:
  my-secret-tls terminates mywebsite.com
Rules:
  Host        Path  Backends
  ----        ----  --------
  *           
              /api/events   my-events-api-svc:80 (10.244.4.145:4000,10.244.5.118:4000)
Annotations:  kubernetes.io/ingress.class: nginx
              nginx.ingress.kubernetes.io/custom-http-errors: 404
Events:
  Type    Reason  Age                From                      Message
  ----    ------  ----               ----                      -------
  Normal  UPDATE  9s (x7 over 153m)  nginx-ingress-controller  Ingress apps/my-ingress

问题是指定的路径不起作用,我收到 404。我注意到在上面的输出中,Host 下有一个 *。我的其他入口配置几乎相同(只是设置了不同的路径),并且 kubectl describe 输出中没有 *。相反,在我的其他入口中,显示了正确的主机 - “mywebsite.com”。

上面的输出也有一些错误 (<error: endpoints "default-http-backend" not found>),但我在其他入口(确实有效)中也看到了它。

可能是什么问题?

这是您的缩进,请检查official example

spec:
  rules:
    - host: hello-world.info
      http:
        paths:

尝试

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: my-ingress
  namespace: apps
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/custom-http-errors: '404'
spec:
  tls:
    - hosts:
        - mywebsite.com
      secretName: my-secret-tls
  rules:
  - host: mywebsite.com
    http:
      paths:
        - path: /api/events
          pathType: ImplementationSpecific
          backend:
            service:
              name: my-events-api-svc
              port:
                number: 80