<p>On one of our domains <a href="https://www.secretwish.in" rel="nofollow noreferrer">https://www.secretwish.in</a> - all the 404 traffic is going to the default GKE Ingress whereas it has to route to my application.</p>

<p>All other pages on my application are working fine, the problem is just with 404 page, all traffic is going on gke default ingress. Sample URL - <a href="https://www.secretwish.in/hshshs" rel="nofollow noreferrer">https://www.secretwish.in/hshshs</a></p>

<p>Need to find a solution for this so that all traffic starts routing to my app</p>

<p>Cluster Version - 1.14.10-gke.27</p>

<p>The ingress file looks like:-</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: ans-commerce-ingress
  annotations:
    kubernetes.io/tls-acme: "true"
    kubernetes.io/ingress.class: "nginx"
    ingress.kubernetes.io/tls-minimum-version: "1.0"
spec:
  tls:      
  - hosts:
    - www.secretwish.in
    secretName: www-secretwish-in-tls    

   - host: www.secretwish.in
     http:
       paths:
       - path: /
         backend:
           serviceName: ans-commerce
           servicePort: 80
</code></pre>

Sushant Puri
<p>In <code>GKE</code> docs you can find information regarding <a href="https://cloud.google.com/kubernetes-engine/docs/concepts/ingress" rel="nofollow noreferrer">GKE Ingress</a>, that for specific <code>path</code> you should specify <code>backend</code>, otherwise you will received issue <code>404 default backend</code>. </p>

<blockquote>
  <p>You can specify a default backend by providing a backend field in your
  Ingress manifest. Any requests that don't match the paths in the rules
  field are sent to the Service and port specified in the backend field.
  ... If you don't specify a default backend, GKE provides a default
  backend that <strong>returns 404.</strong></p>
  
  <p><code>Default backend</code> will redirect all request which could not be found
  in any <code>spec.rules.http.paths.path</code></p>
</blockquote>

<p>For little test I've used 2 <code>deployments</code> and 2 <code>services</code> form <a href="https://cloud.google.com/kubernetes-engine/docs/how-to/load-balance-ingress" rel="nofollow noreferrer">this gke example</a>.</p>

<p><strong>Option 1</strong> without configured <code>default end</code></p>

<pre><code>apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: my-ingress
spec:
  rules:
  - http:
      paths:
      - path: /world
        backend:
          serviceName: hello-world
          servicePort: 60000
      - path: /kube
        backend:
          serviceName: hello-kubernetes
          servicePort: 80

user@cloudshell:~ (prjoect-name)$ curl 35.244.197.176
default backend - 404
user@cloudshell:~ (prjoect-name)$ curl 35.244.197.176/kube
Hello Kubernetes!
user@cloudshell:~ (prjoect-name)$ curl 35.244.197.176/world
Hello, world!
Version: 2.0.0
Hostname: hello-world-deployment-7f67f479f5-vqzxg
user@cloudshell:~ (prjoect-name)$ curl 35.244.197.176/yvgbhuij
default backend - 404 
</code></pre>

<p><strong>Option 2</strong> With defailt backend</p>

<pre><code>apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: my-ingress
spec:
  backend:
    serviceName: hello-world
    servicePort: 60000
  rules:
  - http:
      paths:
      - path: /world
        backend:
          serviceName: hello-world
          servicePort: 60000
      - path: /kube
        backend:
          serviceName: hello-kubernetes
          servicePort: 80

user@cloudshell:~ (prjoect-name)$ curl 35.244.186.95
Hello, world!
Version: 2.0.0
Hostname: hello-world-deployment-7f67f479f5-vqzxg
user@cloudshell:~ (prjoect-name)$ curl 35.244.186.95/hello
Hello, world!
Version: 2.0.0
Hostname: hello-world-deployment-7f67f479f5-kd6fg
user@cloudshell:~ (prjoect-name)$ curl 35.244.186.95/kube
Hello Kubernetes!
user@cloudshell:~ (prjoect-name)$ curl 35.244.186.95/fyvgbhujnkl
Hello, world!
Version: 2.0.0
Hostname: hello-world-deployment-7f67f479f5-vqzxg
</code></pre>

<p><strong>Please keep in mind that Ingress on GKE needs about 5-6 minutes before it starts working properly</strong></p>
