Traefik load balancing weight not working as per expectation

6/7/2019

I have configured the following ingress for traefik but traefik is sending the entire traffic to app-blue-release. Ideally it should send only 30% traffic to blue and 70% traffic to green, but it's not working as per expectation.

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    traefik.frontend.entryPoints: http
    traefik.ingress.kubernetes.io/service-weights: |-
      app-green-release: 70.0
      app-blue-release: 30.0
  creationTimestamp: 2019-06-04T06:00:37Z
  generation: 2
  labels:
    app: traefik-app
  name: traefik-app
  namespace: mynamespace
  resourceVersion: "645536328"
  selfLink: /apis/extensions/v1beta1/namespaces/mynamespace/ingresses/traefik-app
  uid: 4637377-747b-11e9-92ea-005056aeabf7
spec:
  rules:
  - host: mycompany2.com
    http:
      paths:
      - backend:
          serviceName: app-release
          servicePort: 8080
  - host: mycompany.com
    http:
      paths:
      - backend:
          serviceName: app-ui-release
          servicePort: 80
        path: /widget
      - backend:
          serviceName: app-green-release
          servicePort: 8080
        path: /
      - backend:
          serviceName: app-blue-release
          servicePort: 8080
        path: /
status:
  loadBalancer: {}

I am using following traffic version. traefik:v1.7.11-alpine

Earlier when the weight was configured with 10 (for blue) and 90(for green) then it was working fine. But once we changed to 30 and 70 respectively then this problem is happening.

Anyone has faced such issue before. Thanks for your help in advance

-- nagendra547
kubernetes
load-balancing
traefik

1 Answer

6/9/2019

That seems to be followed by traefik issue 4494 (instead of your own issue 4940)

the annotation ingress.kubernetes.io/service-weights has been added in v1.7, before the annotation was ignored.

However, as of June 11th, 2019, Damien Duportal (Træfik's Developer Advocate) adds:

There is no known workaround for now.
We are working on this, but as the version 2.0 of Traefik is currently worked on, we have to wait :)


This comes from PR 3112

Provides a new ingress annotation ingress.kubernetes.io/backend-weights which specifies a YAML-encoded, percentage-based weight distribution. With this annotation, we can do canary release by dynamically adjust the weight of ingress backends.

(called initially ingress.kubernetes.io/percentage-weights before being renamed ingress.kubernetes.io/service-weights in commit 11f6079)

The issue is still pending.
Try first to upgrade to v1.7.12-alpine to check that the issue does persist.

The example mentions:

service_backend1: 1% # Note that the field names must match service names referenced in the Ingress object.
service_backend2: 33.33%
service_backend3: 33.33% # Same as 33.33%, the percentage sign is optional

So in your case, do try:

  app-green-release: 70%
  app-blue-release: 30%
-- VonC
Source: StackOverflow