nginx-ingress responding with "default backend - 404" on google cloud kubernetes cluster

12/9/2020

My program is working great on the local windows environment and I am about to run my program on google cloud Kubernetes cluster and all workloads and services are working fine but when I go to ingress-controller service and open URL, then it shows "default backend - 404". I can't figure out what could be the problem with Nginx-ingress, or there is some special command I need to run? so it could run on google cloud. Can anyone suggest to me some good solutions? it will be great

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress-service
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/rewrite-target: /$1 # rewriting target
spec:
  rules:
    - http:
        paths:
          - path: /?(.*) # this must be in same format -- simple route
            pathType: Prefix
            backend:
              service:
                name: client-cluster-ip-service
                port:
                  number: 3000
          - path: /api/?(.*) # this must be in same format -- here /api will be removed from the route as we did with nginx in docker
            pathType: Prefix
            backend:
              service:
                name: server-cluster-ip-service
                port:
                  number: 5000

This is my ingress-service.yaml file and all is working fine on the local env but I don't understand why this is redirecting me to default backend on production environment - google cloud Kubernetes cluster

-- zohaib butt
gcloud
google-kubernetes-engine
kubernetes
nginx-ingress

0 Answers