<p>How do I set a Kubernentes Ingress and Controller to essentially do what the following nginx.conf file does: </p>

<pre><code>upstream backend {
    server server1.example.com       weight=5;
    server server2.example.com:8080;

    server backup1.example.com:8080   backup;
}
</code></pre>

<p>I want one http endpoint to map to multiple Kubernetes services with a preference for a primary one but also have a backup one. (For my particular project, I need to have multiple services instead of one service with multiple pods.)</p>

<p>Here's my attempted ingress.yaml file. I'm quite certain that the way I'm listing the multiple backends is incorrect. How would I do it? And how do I set the "backup" flag?</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: fanout-ingress
  annotations:
    ingress.kubernetes.io/rewrite-target: /
    kubernetes.io/ingress.class: "nginx"
    # kubernetes.io/ingress.global-static-ip-name: "kubernetes-ingress"
spec:
  rules:
  - http:
      paths:
      - path: /
        backend:
          serviceName: server1
          servicePort: 
      - path: /
        backend:
          serviceName: server2
          servicePort: 8080
      - path: /
        backend:
          serviceName: backup1
          servicePort: 8080
</code></pre>

<p>I'm running Kubernetes on GKE.</p>

<p>You can do <a href="https://kubernetes.io/docs/concepts/services-networking/ingress/#simple-fanout" rel="noreferrer">simple fanout</a> based on path or <a href="https://kubernetes.io/docs/concepts/services-networking/ingress/#name-based-virtual-hosting" rel="noreferrer">name based virtual hosting</a>. </p>

<p>However, you'd need to distinguish based on something (other than port, since it's an Ingress), so your two options would be virtual host or path. </p>

<p>Paths will not work with some services that expect a standard path. Judging based on your example you'd most likely want to have something like a.example.com and b.example.com. Here's the example from the Kubernetes docs:</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: name-virtual-host-ingress
spec:
  rules:
    - host: foo.bar.com
      http:
        paths:
          - backend:
              serviceName: service1
              servicePort: 80
    - host: bar.foo.com
      http:
        paths:
          - backend:
              serviceName: service2
              servicePort: 80
</code></pre>
