Closed prasadrajesh closed 3 weeks ago
Weight based routing is supposed to work with Gateway API:
and also with Ingress resources, see the blue/green example.
Can you update us with a few more detail, like what you tried to do, what was expected and what happened? Maybe you have a bug instead of a feature request.
Hi @jcmoraisjr , I was testing with below httpRoute.
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: coffee
spec:
parentRefs:
- name: cafe
hostnames:
- "test1.prod.test.net"
rules:
- matches:
- path:
type: PathPrefix
value: /
backendRefs:
- name: example-service
port: 80
weight: 90
- name: example-service1
port: 80
weight: 10
And used template https://github.com/jcmoraisjr/haproxy-ingress/blob/master/rootfs/etc/templates/haproxy/haproxy.tmpl
At the end I am getting as below
backend <backend name>
....
server <server1_name> <server1_ip>:8080 weight 256
server <server2_name> <server2_ip>:8080 weight 28
@jcmoraisjr I think you are right this is bug as it should rendered as below
backend <backend name>
....
server <server1_name> <server1_ip>:8080 weight 230
server <server2_name> <server2_ip>:8080 weight 26
Hi, the actual weight calculation is made by using the maximum weight value haproxy supports, which is 256. The important part here is to ensure that the actual values are as much close to the provided ones as possible, and you can ensure that by dividing 90/10 (9) and 256/28 (9,14). Your proposed weight is btw also correct, but using a distinct calculation haproxy ingress currently uses.
This issue got stale and will be closed in 7 days.
What are you trying to do I am trying to use weight based routing on backend (feature of HAProxy) to make sure I can use canary deployment to switch traffic for same hostname/FQDN.
What HAProxy Ingress should do or how it should behave differently I tested with provided default template in this repo. But the controller can't add custom weight at backend. Even I looked the code https://github.com/jcmoraisjr/haproxy-ingress/blob/master/pkg/converters/gateway/gateway.go seems no logic implemented here. Please correct me if I am wrong.