<p>I tried to setup a Kubernetes Ingress to route external http traffic towards a frontend pod (with path /) and backend pod (with path /rest/*), but I alway get a 400 error instead of the main nginx index.html.</p>

<p>So I tried the Google Kubernetes example at page <a href="https://cloud.google.com/kubernetes-engine/docs/tutorials/http-balancer" rel="nofollow noreferrer">https://cloud.google.com/kubernetes-engine/docs/tutorials/http-balancer</a>, but I get always a 400 error. Any idea?</p>

<p>Following is the deployment descriptor for the frontend "cup-fe" (running nginx with angular app):</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: cup-fe
  namespace: default
  labels:
    app: cup-fe
spec:
  replicas: 2
  selector:
    matchLabels:
      app: "cup-fe"
  template:
    metadata:
      labels:
        app: "cup-fe"
    spec:
      containers:
      - image: "eu.gcr.io/gpi-cup-242708/cup-fe:latest"
        name: "cup-fe"
</code></pre>

<p>Next the service NodePort:</p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: cup-fe
  namespace: default
spec:
  ports:
  - name: http
    port: 80
    protocol: TCP
    targetPort: 80
  selector:
    run: cup-fe
  type: NodePort
</code></pre>

<p>And last, but not least, the Ingress to expose the frontend outside:</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: http-ingress
spec:
  rules:
  - host: cup-fe
    http:
      paths:
      - path: /
        backend:
          serviceName: cup-fe
          servicePort: 80
      - path: /rest/*
        backend:
          serviceName: cup-be
          servicePort: 8080
</code></pre>

<p>I left behind "cup-be" deployment descriptor (running wildfly), because is pretty similar to the "cup-fe" one. Please note also that if I create a LoadBalancer service instead of NodePort, I can reach the web page but I have some CORS problems to call the backend.</p>

duns
<p>I assume that you have used wrong <a href="https://kubernetes.io/docs/concepts/overview/working-with-objects/field-selectors/" rel="nofollow noreferrer">selector</a> <code>run: cup-fe</code> entire particular service configuration. Since I have replaced label with <code>app: cup-fe</code> in <code>cup-fe</code> service configuration the relevant Pod <a href="https://kubernetes.io/docs/concepts/services-networking/service/#services-without-selectors" rel="nofollow noreferrer">endpoints</a> showed up and I've received successful responses as well.</p>

<pre><code>$ kubectl get ep | grep cup-fe|awk '{print $2}'
&lt;IP_address&gt;:80,&lt;IP_address&gt;:80
</code></pre>

<p>If the issue still persists just let me know and push a comment below my answer.</p>
