Home > Net >  Kubernetes Ingress does not match host
Kubernetes Ingress does not match host

Time:07-06

I'm trying to create an ingress rule for a backend service. The ingress controller is the Microk8s Nginx ingress. If I set the host, the ingress stops matching the backend, resulting in a 404 when I visit https://my-host.com

Here is my code:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
    nginx.ingress.kubernetes.io/rewrite-target: /
    kubernetes.io/ingress.class: public
  name: http-ingress
spec:
  tls:
    - hosts:
        - "my-host.com"
      secretName: nginx-ingress
  rules:
    - host: "my-host.com"
    - http:
        paths:
          - pathType: Prefix
            path: /
            backend:
              service:
                name: some-service
                port:
                  number: 80

CodePudding user response:

You have created 2 rules, one with only host and a second with http: .... It should be

rules:
    - host: "my-host.com"
      http:
        paths:

Yes, YAML is evil.

  • Related