skip to Main Content

I have created a kubernetes cluster using Vagrant. I created a Nginx pod and a Cluster IP service for it. I can curl both the pod and the service getting a successful result. I have now installed an Nginx Ingress Controller from: https://kubernetes.github.io/ingress-nginx/deploy/#bare-metal-clusters and ran the following command:
kubectl create ingress nginxingress --rule="/nginx=nginx-service:80" --annotation nginx.ingress.kubernetes.io/rewrite-target=/ --default-backend=nginx-service:80 and they both have been setup correctly as far as I see as there are no errors. But whenever I try to curl the path then it fails, the controller keeps throwing a 404 Not found.
Some more information that might help:
services:
enter image description here
ingresses:
enter image description here
any help will be greatly appreciated

2

Answers


  1. Try adding the ingress class annotation to the ingress configuration. kubernetes.io/ingress.class: "nginx"

    use below YAML as reference and try to update the configuration.

    apiVersion: networking.k8s.io/v1
    kind: Ingress
    metadata:
      name: ingress-myserviceb
      annotations:
        kubernetes.io/ingress.class: "nginx"
    spec:
      rules:
      - host: myserviceb.foo.org
        http:
          paths:
          - path: /nginx
            pathType: Prefix
            backend:
              service:
                name: nginx-service
                port:
                  number: 80
    
    Login or Signup to reply.
  2. Had the same problem but was already using kubernetes.io/ingress.class: "nginx" as in Harsh Manvar answer.

    If you need to match multiple URLs and not only the basic host URL like me, on your ingress use:

    1. spec.rules.[your-host].path: "/(.*)"
    2. spec.rules.[your-host].path: Prefix
    3. metadata.annotations.nginx.ingress.kubernetes.io/use-regex: "true"

    More detail about this config here

    OBS: some times update a ingress dosent work, you may need to delete and recreate the ingress.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search