mnj
mnj

Reputation: 3413

Ingress uses wildcard, although I didn't specify that

I have the following ingress:

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

When I kubectl describe this ingress, I see the following

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

The issue is that the specified path doesn't work, I'm getting 404. I noticed that in the output above, there is a * under the Host. My other ingresses are configured pretty much the same (only have different paths set), and there is no * in the kubectl describe output. Instead, in my other ingresses the proper Host - "mywebsite.com" - is shown.

The output above also has some error (<error: endpoints "default-http-backend" not found>), but I see it as well in my other ingresses (that do work).

What could be the problem?

Upvotes: 0

Views: 1056

Answers (1)

Vit
Vit

Reputation: 8421

Its your indentation, please check official example

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

Try

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

Upvotes: 1

Related Questions