<p>I have a kubernetes ingress of class <code>nginx</code> and two load balancers. Running on GKE v1.17.</p>
<p>Sample ingress yaml:</p>
<pre><code>apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: my-ingress
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /$1
    nginx.ingress.kubernetes.io/backend-protocol: &quot;HTTPS&quot;
    kubernetes.io/ingress.class: &quot;nginx&quot;
    # Enable client certificate authentication
    nginx.ingress.kubernetes.io/auth-tls-verify-client: &quot;on&quot;
    # Create the secret containing the trusted ca certificates
    nginx.ingress.kubernetes.io/auth-tls-secret: &quot;production/client-cert-secret&quot;
    # Specify the verification depth in the client certificates chain
    nginx.ingress.kubernetes.io/auth-tls-verify-depth: &quot;1&quot;
    # Automatically redirect http to https
    nginx.ingress.kubernetes.io/force-ssl-redirect: &quot;true&quot;
    # Use regex in paths
    nginx.ingress.kubernetes.io/use-regex: &quot;true&quot;
    # Allow larger request body
    nginx.ingress.kubernetes.io/proxy-body-size: 30m
    # For notifications we add the proxy headers
    nginx.ingress.kubernetes.io/configuration-snippet: |  
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection &quot;upgrade&quot;;
spec:
  tls:
    - hosts:
      - my-domain.com
      secretName: my-tls-certificate
  rules:
  - host: my-domain.com
    http:
      paths:
      - path: /(.*)
        backend:
          serviceName: load-balancer-1
          servicePort: 443
</code></pre>
<p>I wish to split the traffic reached to the ingress between the two load balancers.
For example:</p>
<p><code>load-balancer-1</code> will receive 90% of the traffic</p>
<p><code>load-balancer-2</code> will receive 10% of the traffic</p>
<p><strong>How can I do that with kubernetes ingress?</strong></p>

<p>The nginx ingress controller supports canary deployments through the <a href="https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/annotations/#canary" rel="noreferrer">Canary Annotations</a></p>
<blockquote>
<p>In some cases, you may want to &quot;canary&quot; a new set of changes by
sending a small number of requests to a different service than the
production service. The canary annotation enables the Ingress spec to
act as an alternative service for requests to route to depending on
the rules applied. The following annotations to configure canary can
be enabled after <code>nginx.ingress.kubernetes.io/canary: &quot;true&quot;</code> is set:</p>
<ul>
<li><code>nginx.ingress.kubernetes.io/canary-weight</code>: The integer based (0 - 100)
percent of random requests that should be routed to the service
specified in the canary Ingress. A weight of 0 implies that no
requests will be sent to the service in the Canary ingress by this
canary rule. A weight of 100 means implies all requests will be sent
to the alternative service specified in the Ingress.</li>
</ul>
<p>Note that when you mark an ingress as canary, then all the other
non-canary annotations will be ignored (inherited from the
corresponding main ingress) except
nginx.ingress.kubernetes.io/load-balance and
nginx.ingress.kubernetes.io/upstream-hash-by.</p>
<p><strong>Known Limitations</strong></p>
<p>Currently a maximum of one canary ingress can be applied per Ingress
rule.</p>
</blockquote>
<p>In other words, you can introduce a new Ingress Object <code>my-ingress-canary</code> where you set the annotations</p>
<ul>
<li><p><code>nginx.ingress.kubernetes.io/canary: &quot;true&quot;</code> (Tells Nginx Ingress to mark this one as “Canary” and associate this ingress with the main ingress by matching host and path.</p>
</li>
<li><p><code>nginx.ingress.kubernetes.io/canary-weight: &quot;10&quot;</code> (Route ten percent traffic to load-balancer-2)</p>
</li>
</ul>
<pre><code>apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: my-ingress-canary
  annotations:
    nginx.ingress.kubernetes.io/canary: &quot;true&quot;
    nginx.ingress.kubernetes.io/canary-weight: &quot;10&quot;
spec:
  rules:
  - host: my-domain.com
    http:
      paths:
      - path: /(.*)
        backend:
          serviceName: load-balancer-2
          servicePort: 443

</code></pre>
