-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Implement weighted round robin load balancing strategy #50
Comments
The round robin is taken care of by our library https://github.com/k8gb-io/go-weight-shuffling, which shuffles the indexes in the array according to the predefined weights. The library would run in the new CoreDNS external plugin within https://github.com/k8gb-io/coredns-crd-plugin. Data will be fed into this plugin from annotation within external DNS endpoints. The CoreDNS - external DNS plugin will read these annotations and arrange itself accordingly. One cluster can have a number of IP addresses that can change from time to time. The N% weight is set per cluster (region), so I need [
{region: "eu", weightPercent: 20, targets:["172.18.0.5","172.18.0.6"]},
{region: "us", weightPercent:80, targets:["172.18.0.1","172.18.0.2"]}
] apiVersion: externaldns.k8s.io/v1alpha1
kind: DNSEndpoint
metadata:
annotations:
k8gb.absa.oss/dnstype: local
k8gb.absa.oss/weight-round-robin: '[{"region":"eu","weightPercent":20,"targets":["172.18.0.5","172.18.0.6"]},{"region":"us","weightPercent":80,"targets":["172.18.0.1","172.18.0.2"]}]'
name: k8gb-ns-extdns
namespace: k8gb |
Related to #50 weight is also allowed for failower and geoip, although it will be ignored by controller. Signed-off-by: kuritka <kuritka@gmail.com>
Related to #50 The weight configuration goes into the GSLB strategy. This PR only aims to load and validate the weight configuration, which is specified in percentages. ```yaml strategy: type: roundRobin # Use a round robin load balancing strategy, when deciding which downstream clusters to route clients too weight: 20% ``` gslb.spec.strategy.weight is not allowed for failover and geoip strategies. If it is not specified in roundRobin, then it is not a weight RoundRobin but classic one. Signed-off-by: kuritka <kuritka@gmail.com> move RoundRobinStrategy, FailoverStrategy, GeoStrategy constants into depresolver package
Related to #50 The weight configuration goes into the GSLB strategy. This PR only aims to load and validate the weight configuration, which is specified in percentages. ```yaml strategy: type: roundRobin # Use a round robin load balancing strategy, when deciding which downstream clusters to route clients too weight: 20% ``` gslb.spec.strategy.weight is not allowed for failover and geoip strategies. If it is not specified in roundRobin, then it is not a weight RoundRobin but classic one. Signed-off-by: kuritka <kuritka@gmail.com> move RoundRobinStrategy, FailoverStrategy, GeoStrategy constants into depresolver package
Related to #50 The weight configuration goes into the GSLB strategy. This PR only aims to load and validate the weight configuration, which is specified in percentages. ```yaml strategy: type: roundRobin # Use a round robin load balancing strategy, when deciding which downstream clusters to route clients too weight: 20% ``` gslb.spec.strategy.weight is not allowed for failover and geoip strategies. If it is not specified in roundRobin, then it is not a weight RoundRobin but classic one. Signed-off-by: kuritka <kuritka@gmail.com> move RoundRobinStrategy, FailoverStrategy, GeoStrategy constants into depresolver package
Related to #50 The weight configuration goes into the GSLB strategy. This PR only aims to load and validate the weight configuration, which is specified in percentages. ```yaml strategy: type: roundRobin # Use a round robin load balancing strategy, when deciding which downstream clusters to route clients too weight: 20% ``` gslb.spec.strategy.weight is not allowed for failover and geoip strategies. If it is not specified in roundRobin, then it is not a weight RoundRobin but classic one. Signed-off-by: kuritka <kuritka@gmail.com> move RoundRobinStrategy, FailoverStrategy, GeoStrategy constants into depresolver package
Related to #50 The weight (optional field) configuration goes into the GSLB strategy. This PR only aims to load and validate the weight configuration, which is specified in percentages. ```yaml strategy: type: roundRobin # Use a round robin load balancing strategy, when deciding which downstream clusters to route clients too weight: 20% ``` gslb.spec.strategy.weight is not allowed for failover and geoip strategies. If it is not specified in roundRobin, then it is not a weight RoundRobin but classic one. Signed-off-by: kuritka <kuritka@gmail.com> move RoundRobinStrategy, FailoverStrategy, GeoStrategy constants into depresolver package
Related to #50 The weight (optional field) configuration goes into the GSLB strategy. This PR only aims to load and validate the weight configuration, which is specified in percentages. The weight distribution must be available to all clusters, so the weight field contains the weights of all regions. ```yaml strategy: type: roundRobin # Use a round robin load balancing strategy, when deciding which downstream clusters to route clients too weight: us: 60% eu: 15% za: 25% ``` gslb.spec.strategy.weight is not allowed for failover and geoip strategies. If it is not specified in roundRobin, then it is not a weight RoundRobin but classic one. Signed-off-by: kuritka <kuritka@gmail.com> move RoundRobinStrategy, FailoverStrategy, GeoStrategy constants into depresolver package Weights configuration UPDATE To be able to round robin by weight I must update GSLB spec contract. instead of ```yaml spec: strategy: roundRobin weight: 20% ``` I must extend with map: ```yaml spec: strategy: roundRobin weight: us: 20% eu: 80% ``` Signed-off-by: kuritka <kuritka@gmail.com>
Related to #50 The weight (optional field) configuration goes into the GSLB strategy. This PR only aims to load and validate the weight configuration, which is specified in percentages. The weight distribution must be available to all clusters, so the weight field contains the weights of all regions. ```yaml strategy: type: roundRobin # Use a round robin load balancing strategy, when deciding which downstream clusters to route clients too weight: us: 60% eu: 15% za: 25% ``` gslb.spec.strategy.weight is not allowed for failover and geoip strategies. If it is not specified in roundRobin, then it is not a weight RoundRobin but classic one. Signed-off-by: kuritka <kuritka@gmail.com>
Related to #50 The weight (optional field) configuration goes into the GSLB strategy. This PR only aims to load and validate the weight configuration, which is specified in percentages. The weight distribution must be available to all clusters, so the weight field contains the weights of all regions. ```yaml strategy: type: roundRobin # Use a round robin load balancing strategy, when deciding which downstream clusters to route clients too weight: us: 60% eu: 15% za: 25% ``` gslb.spec.strategy.weight is not allowed for failover and geoip strategies. If it is not specified in roundRobin, then it is not a weight RoundRobin but classic one. Signed-off-by: kuritka <kuritka@gmail.com>
related to #50 implemented code that adds an annotation to the local dnsEndpoint. - covered by unit-tests - the annotation is as follows: ```json { "eu":{ "weight":35, "targets":[ "10.10.0.1", "10.10.0.2" ] }, "us":{ "weight":50, "targets":[ "10.0.0.1", "10.0.0.2" ] }, "za":{ "weight":15, "targets":[ "10.22.0.1", "10.22.0.2", "10.22.1.1" ] } } ``` ``` Signed-off-by: kuritka <kuritka@gmail.com>
related to #50 implemented code that adds an annotation to the local dnsEndpoint. - covered by unit-tests - the annotation is as follows: ```json { "eu":{ "weight":35, "targets":[ "10.10.0.1", "10.10.0.2" ] }, "us":{ "weight":50, "targets":[ "10.0.0.1", "10.0.0.2" ] }, "za":{ "weight":15, "targets":[ "10.22.0.1", "10.22.0.2", "10.22.1.1" ] } } ``` Signed-off-by: kuritka <kuritka@gmail.com>
related to #50 implemented code that adds an annotation to the local dnsEndpoint. - covered by unit-tests - the annotation is as follows: ```json { "eu":{ "weight":35, "targets":[ "10.10.0.1", "10.10.0.2" ] }, "us":{ "weight":50, "targets":[ "10.0.0.1", "10.0.0.2" ] }, "za":{ "weight":15, "targets":[ "10.22.0.1", "10.22.0.2", "10.22.1.1" ] } } ``` Signed-off-by: kuritka <kuritka@gmail.com>
related to #50 implemented code that adds an annotation to the local dnsEndpoint. - covered by unit-tests - the annotation is as follows: ```json { "eu":{ "weight":35, "targets":[ "10.10.0.1", "10.10.0.2" ] }, "us":{ "weight":50, "targets":[ "10.0.0.1", "10.0.0.2" ] }, "za":{ "weight":15, "targets":[ "10.22.0.1", "10.22.0.2", "10.22.1.1" ] } } ``` Signed-off-by: kuritka <kuritka@gmail.com>
related to #50 implemented code that adds an annotation to the local dnsEndpoint. - covered by unit-tests - the annotation is as follows: ```json { "eu":{ "weight":35, "targets":[ "10.10.0.1", "10.10.0.2" ] }, "us":{ "weight":50, "targets":[ "10.0.0.1", "10.0.0.2" ] }, "za":{ "weight":15, "targets":[ "10.22.0.1", "10.22.0.2", "10.22.1.1" ] } } ``` Signed-off-by: kuritka <kuritka@gmail.com>
related to #50 implemented code that adds labels to the local dnsEndpoint. - covered by unit-tests - the labels are as follows: ```yaml kind: GSLB spec: ingress: rules: - host: roundrobin.cloud.example.com http: # This section mirrors the same structure as that of an Ingress resource and will be used verbatim when creating the corresponding Ingress resource that will match the GSLB host paths: - path: / backend: service: name: existing-app # Gslb should reflect NotFound status port: name: http spec: strategy: roundRobin weight: eu: 20% us: 50% za: 30% ``` has local DNS endpoint like this: ```yaml apiVersion: externaldns.k8s.io/v1alpha1 kind: DNSEndpoint metadata: name: app_host spec: endpoints: - dnsName: app.bar.com labels: weight-us-0-50: 10.0.0.1 weight-us-1-50: 10.0.0.2 weight-eu-0-20: 10.10.0.1 weight-eu-1-20: 10.0.0.2 weight-za-0-30: 10.22.0.1 recordTTL: 180 recordType: A targets: - 10.0.0.1 - 10.0.0.2 - 10.10.0.1 - 10.0.0.2 - 10.22.0.1 ``` Signed-off-by: kuritka <kuritka@gmail.com>
related to #50 implemented code that adds labels to the local dnsEndpoint. - covered by unit-tests - the labels are as follows: ```yaml kind: GSLB spec: ingress: rules: - host: roundrobin.cloud.example.com http: # This section mirrors the same structure as that of an Ingress resource and will be used verbatim when creating the corresponding Ingress resource that will match the GSLB host paths: - path: / backend: service: name: existing-app # Gslb should reflect NotFound status port: name: http spec: strategy: roundRobin weight: eu: 35% us: 50% za: 15% ``` has local DNS endpoint like this: ```yaml apiVersion: externaldns.k8s.io/v1alpha1 kind: DNSEndpoint metadata: name: app_host annotations: k8gb.absa.oss/dnstype: local spec: endpoints: - dnsName: app.bar.com labels: weight-eu-0-35: 10.10.0.1 weight-eu-1-35: 10.10.0.2 weight-us-0-50: 10.0.0.1 weight-us-1-50: 10.0.0.2 weight-za-0-15: 10.22.0.1 weight-za-1-15: 10.22.0.2 weight-za-2-15: 10.22.1.1 recordTTL: 180 recordType: A Targets: - 10.10.0.1 - 10.10.0.2 - 10.0.0.1 - 10.0.0.2 - 10.22.0.1 - 10.22.0.2 - 10.22.1.1 ``` Signed-off-by: kuritka <kuritka@gmail.com>
related to #50 implemented code that adds labels to the local dnsEndpoint. - covered by unit-tests - the labels are as follows: ```yaml kind: GSLB spec: ingress: rules: - host: roundrobin.cloud.example.com http: # This section mirrors the same structure as that of an Ingress resource and will be used verbatim when creating the corresponding Ingress resource that will match the GSLB host paths: - path: / backend: service: name: existing-app # Gslb should reflect NotFound status port: name: http spec: strategy: roundRobin weight: eu: 35% us: 50% za: 15% ``` has local DNS endpoint like this: ```yaml apiVersion: externaldns.k8s.io/v1alpha1 kind: DNSEndpoint metadata: name: app_host annotations: k8gb.absa.oss/dnstype: local spec: endpoints: - dnsName: app.bar.com labels: weight-eu-0-35: 10.10.0.1 weight-eu-1-35: 10.10.0.2 weight-us-0-50: 10.0.0.1 weight-us-1-50: 10.0.0.2 weight-za-0-15: 10.22.0.1 weight-za-1-15: 10.22.0.2 weight-za-2-15: 10.22.1.1 recordTTL: 180 recordType: A Targets: - 10.10.0.1 - 10.10.0.2 - 10.0.0.1 - 10.0.0.2 - 10.22.0.1 - 10.22.0.2 - 10.22.1.1 ``` Signed-off-by: kuritka <kuritka@gmail.com>
related to #50 implemented code that adds labels to the local dnsEndpoint. - covered by unit-tests - the labels are as follows: ```yaml kind: GSLB spec: ingress: rules: - host: roundrobin.cloud.example.com http: # This section mirrors the same structure as that of an Ingress resource and will be used verbatim when creating the corresponding Ingress resource that will match the GSLB host paths: - path: / backend: service: name: existing-app # Gslb should reflect NotFound status port: name: http spec: strategy: roundRobin weight: eu: 35% us: 50% za: 15% ``` has local DNS endpoint like this: ```yaml apiVersion: externaldns.k8s.io/v1alpha1 kind: DNSEndpoint metadata: name: app_host annotations: k8gb.absa.oss/dnstype: local spec: endpoints: - dnsName: app.bar.com labels: weight-eu-0-35: 10.10.0.1 weight-eu-1-35: 10.10.0.2 weight-us-0-50: 10.0.0.1 weight-us-1-50: 10.0.0.2 weight-za-0-15: 10.22.0.1 weight-za-1-15: 10.22.0.2 weight-za-2-15: 10.22.1.1 recordTTL: 180 recordType: A Targets: - 10.10.0.1 - 10.10.0.2 - 10.0.0.1 - 10.0.0.2 - 10.22.0.1 - 10.22.0.2 - 10.22.1.1 ``` Signed-off-by: kuritka <kuritka@gmail.com>
related to #50 implemented code that adds labels to the local dnsEndpoint. - covered by unit-tests - the labels are as follows: ```yaml kind: GSLB spec: ingress: rules: - host: roundrobin.cloud.example.com http: # This section mirrors the same structure as that of an Ingress resource and will be used verbatim when creating the corresponding Ingress resource that will match the GSLB host paths: - path: / backend: service: name: existing-app # Gslb should reflect NotFound status port: name: http spec: strategy: roundRobin weight: eu: 35% us: 50% za: 15% ``` has local DNS endpoint like this: ```yaml apiVersion: externaldns.k8s.io/v1alpha1 kind: DNSEndpoint metadata: name: app_host annotations: k8gb.absa.oss/dnstype: local spec: endpoints: - dnsName: app.bar.com labels: weight-eu-0-35: 10.10.0.1 weight-eu-1-35: 10.10.0.2 weight-us-0-50: 10.0.0.1 weight-us-1-50: 10.0.0.2 weight-za-0-15: 10.22.0.1 weight-za-1-15: 10.22.0.2 weight-za-2-15: 10.22.1.1 recordTTL: 180 recordType: A Targets: - 10.10.0.1 - 10.10.0.2 - 10.0.0.1 - 10.0.0.2 - 10.22.0.1 - 10.22.0.2 - 10.22.1.1 ``` Signed-off-by: kuritka <kuritka@gmail.com>
related to #50 implemented code that adds labels to the local dnsEndpoint. - covered by unit-tests - the labels are as follows: ```yaml kind: GSLB spec: ingress: rules: - host: roundrobin.cloud.example.com http: # This section mirrors the same structure as that of an Ingress resource and will be used verbatim when creating the corresponding Ingress resource that will match the GSLB host paths: - path: / backend: service: name: existing-app # Gslb should reflect NotFound status port: name: http spec: strategy: roundRobin weight: eu: 35% us: 50% za: 15% ``` has local DNS endpoint like this: ```yaml apiVersion: externaldns.k8s.io/v1alpha1 kind: DNSEndpoint metadata: name: app_host annotations: k8gb.absa.oss/dnstype: local spec: endpoints: - dnsName: app.bar.com labels: weight-eu-0-35: 10.10.0.1 weight-eu-1-35: 10.10.0.2 weight-us-0-50: 10.0.0.1 weight-us-1-50: 10.0.0.2 weight-za-0-15: 10.22.0.1 weight-za-1-15: 10.22.0.2 weight-za-2-15: 10.22.1.1 recordTTL: 180 recordType: A Targets: - 10.10.0.1 - 10.10.0.2 - 10.0.0.1 - 10.0.0.2 - 10.22.0.1 - 10.22.0.2 - 10.22.1.1 ``` Signed-off-by: kuritka <kuritka@gmail.com>
related to #50 implemented code that adds labels to the local dnsEndpoint. - covered by unit-tests - the labels are as follows: ```yaml kind: GSLB spec: ingress: rules: - host: roundrobin.cloud.example.com http: # This section mirrors the same structure as that of an Ingress resource and will be used verbatim when creating the corresponding Ingress resource that will match the GSLB host paths: - path: / backend: service: name: existing-app # Gslb should reflect NotFound status port: name: http spec: strategy: roundRobin weight: eu: 35% us: 50% za: 15% ``` has local DNS endpoint like this: ```yaml apiVersion: externaldns.k8s.io/v1alpha1 kind: DNSEndpoint metadata: name: app_host annotations: k8gb.absa.oss/dnstype: local spec: endpoints: - dnsName: app.bar.com labels: weight-eu-0-35: 10.10.0.1 weight-eu-1-35: 10.10.0.2 weight-us-0-50: 10.0.0.1 weight-us-1-50: 10.0.0.2 weight-za-0-15: 10.22.0.1 weight-za-1-15: 10.22.0.2 weight-za-2-15: 10.22.1.1 recordTTL: 180 recordType: A Targets: - 10.10.0.1 - 10.10.0.2 - 10.0.0.1 - 10.0.0.2 - 10.22.0.1 - 10.22.0.2 - 10.22.1.1 ``` Signed-off-by: kuritka <kuritka@gmail.com>
related to #50 implemented code that adds labels to the local dnsEndpoint. - covered by unit-tests - the labels are as follows: ```yaml kind: GSLB spec: ingress: rules: - host: roundrobin.cloud.example.com http: # This section mirrors the same structure as that of an Ingress resource and will be used verbatim when creating the corresponding Ingress resource that will match the GSLB host paths: - path: / backend: service: name: existing-app # Gslb should reflect NotFound status port: name: http spec: strategy: roundRobin weight: eu: 35% us: 50% za: 15% ``` has local DNS endpoint like this: ```yaml apiVersion: externaldns.k8s.io/v1alpha1 kind: DNSEndpoint metadata: name: app_host annotations: k8gb.absa.oss/dnstype: local spec: endpoints: - dnsName: app.bar.com labels: weight-eu-0-35: 10.10.0.1 weight-eu-1-35: 10.10.0.2 weight-us-0-50: 10.0.0.1 weight-us-1-50: 10.0.0.2 weight-za-0-15: 10.22.0.1 weight-za-1-15: 10.22.0.2 weight-za-2-15: 10.22.1.1 recordTTL: 180 recordType: A Targets: - 10.10.0.1 - 10.10.0.2 - 10.0.0.1 - 10.0.0.2 - 10.22.0.1 - 10.22.0.2 - 10.22.1.1 ``` Signed-off-by: kuritka <kuritka@gmail.com>
@kuritka sorry if I'm coming late to the party, but I've tried to check settings for different implementations of WRR, and in most cases, WRR weights are provided as positive integer instead of percentage: https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/routing-policy-weighted.html The resulting percentage for a particular member can be calculated as a proportion of the total weight of all the members in the WRR group. This way users also don't have to keep in mind the rule of having |
It's more about the point of view. The change is a little more extensive, but not complex. Currently it works with percentages and accept values values like "100", "100%",100,100% But I can change it so that the results are equivalent # current
weight:
us: 50%
eu: 30%
za: 20
uk: 0%
# new alternative (integers distribution)
weight:
us: 50
eu: 30
za: 20
uk: 0
weight:
us: 5
eu: 3
za: 2
uk: 0
weight:
us: 64
eu: 38
za: 26
uk: 0
|
@kuritka Yep, so my point is that by using percentages we're forcing users to think in % and keep the "100% in total" rule in mind. |
ok, will keep it consistent with route53 style and refactor k8gb controller to integers. |
related to k8gb-io/k8gb#50 there is difference between those two: ```yaml strategy: type: roundRobin splitBrainThresholdSeconds: 300 dnsTtlSeconds: 30 ``` ```yaml strategy: type: roundRobin splitBrainThresholdSeconds: 300 dnsTtlSeconds: 30 weight: eu: 1 us: 1 ``` the difference is that first one provides standard coreDNS `loadbalance round_robin`(RRR) while second one enables WRR. We cannot easily switch the configuration in corefile to enable RRR once and WRR the second time. This PR contains functionality that switches from WRR to RRR and vice versa in case it identifies missing weights. ```shell k8gb-coredns-5454ddd5b7-r555w coredns [INFO] plugin/wrr: [random][172.18.0.3 172.18.0.4 172.18.0.6 172.18.0.5] k8gb-coredns-5454ddd5b7-r555w coredns [INFO] plugin/wrr: [random][172.18.0.6 172.18.0.3 172.18.0.4 172.18.0.5] k8gb-coredns-5454ddd5b7-r555w coredns [INFO] plugin/wrr: [random][172.18.0.4 172.18.0.3 172.18.0.5 172.18.0.6] k8gb-coredns-5454ddd5b7-r555w coredns [INFO] plugin/wrr: [1 0][us1 eu1]: [172.18.0.5 172.18.0.6 172.18.0.3 172.18.0.4] k8gb-coredns-5454ddd5b7-r555w coredns [INFO] plugin/wrr: [0 1][eu1 us1]: [172.18.0.3 172.18.0.4 172.18.0.5 172.18.0.6] k8gb-coredns-5454ddd5b7-r555w coredns [INFO] plugin/wrr: [1 0][us1 eu1]: [172.18.0.5 172.18.0.6 172.18.0.4 172.18.0.3] k8gb-coredns-5454ddd5b7-r555w coredns [INFO] plugin/wrr: [random][172.18.0.6 172.18.0.3 172.18.0.5 172.18.0.4] k8gb-coredns-5454ddd5b7-r555w coredns [INFO] plugin/wrr: [random][172.18.0.6 172.18.0.5 172.18.0.3 172.18.0.4] ``` Signed-off-by: kuritka <kuritka@gmail.com>
related to k8gb-io/k8gb#50 there is difference between those three: ```yaml strategy: type: roundRobin splitBrainThresholdSeconds: 300 dnsTtlSeconds: 30 ``` ```yaml strategy: type: roundRobin splitBrainThresholdSeconds: 300 dnsTtlSeconds: 30 weight: eu: 1 us: 1 ``` ```yaml strategy: type: roundRobin splitBrainThresholdSeconds: 300 dnsTtlSeconds: 30 weight: eu: 1 ``` the difference is that first one provides standard coreDNS `loadbalance round_robin`(RRR) while second one enables WRR. We cannot easily switch the configuration in corefile to enable RRR once and WRR the second time when GSLB configuration has change. This PR contains functionality that switches from WRR to RRR and vice versa in case it identifies missing weights. Than I'm reusing CoreDNS loadbalance to perform RRR. If GSLB weight configuration is invalid, balancing is off `[skipping][IPs...]` message is shown and IPs are retreived without shuffling (In same order as they come). ```shell k8gb-coredns-5454ddd5b7-r555w coredns [INFO] plugin/wrr: [random][172.18.0.3 172.18.0.4 172.18.0.6 172.18.0.5] k8gb-coredns-5454ddd5b7-r555w coredns [INFO] plugin/wrr: [random][172.18.0.6 172.18.0.3 172.18.0.4 172.18.0.5] k8gb-coredns-5454ddd5b7-r555w coredns [INFO] plugin/wrr: [random][172.18.0.4 172.18.0.3 172.18.0.5 172.18.0.6] k8gb-coredns-5454ddd5b7-r555w coredns [INFO] plugin/wrr: [1 0][us1 eu1]: [172.18.0.5 172.18.0.6 172.18.0.3 172.18.0.4] k8gb-coredns-5454ddd5b7-r555w coredns [INFO] plugin/wrr: [0 1][eu1 us1]: [172.18.0.3 172.18.0.4 172.18.0.5 172.18.0.6] k8gb-coredns-5454ddd5b7-r555w coredns [INFO] plugin/wrr: [1 0][us1 eu1]: [172.18.0.5 172.18.0.6 172.18.0.4 172.18.0.3] k8gb-coredns-5454ddd5b7-r555w coredns [INFO] plugin/wrr: [random][172.18.0.6 172.18.0.3 172.18.0.5 172.18.0.4] k8gb-coredns-5454ddd5b7-r555w coredns [INFO] plugin/wrr: [random][172.18.0.6 172.18.0.5 172.18.0.3 172.18.0.4] k8gb-coredns-79458796bb-mq855 coredns [INFO] plugin/wrr: [skipping][172.18.0.5 172.18.0.6 172.18.0.3 172.18.0.4] k8gb-coredns-79458796bb-mq855 coredns [INFO] plugin/wrr: [skipping][172.18.0.5 172.18.0.6 172.18.0.3 172.18.0.4] k8gb-coredns-79458796bb-mq855 coredns [INFO] plugin/wrr: [skipping][172.18.0.5 172.18.0.6 172.18.0.3 172.18.0.4] k8gb-coredns-79458796bb-mq855 coredns [INFO] plugin/wrr: [1 0][us1 eu1]: [172.18.0.5 172.18.0.6 172.18.0.4 172.18.0.3] k8gb-coredns-79458796bb-mq855 coredns [INFO] plugin/wrr: [0 1][eu1 us1]: [172.18.0.3 172.18.0.4 172.18.0.5 172.18.0.6] ``` Signed-off-by: kuritka <kuritka@gmail.com>
related to k8gb-io/k8gb#50 there is difference between those three: ```yaml strategy: type: roundRobin splitBrainThresholdSeconds: 300 dnsTtlSeconds: 30 ``` ```yaml strategy: type: roundRobin splitBrainThresholdSeconds: 300 dnsTtlSeconds: 30 weight: eu: 1 us: 1 ``` ```yaml strategy: type: roundRobin splitBrainThresholdSeconds: 300 dnsTtlSeconds: 30 weight: eu: 1 ``` the difference is that first one provides standard coreDNS `loadbalance round_robin`(RRR) while second one enables WRR. We cannot easily switch the configuration in corefile to enable RRR once and WRR the second time when GSLB configuration has change. This PR contains functionality that switches from WRR to RRR and vice versa in case it identifies missing weights. Than I'm reusing CoreDNS loadbalance to perform RRR. If GSLB weight configuration is invalid, balancing is off `[skipping][IPs...]` message is shown and IPs are retreived without shuffling (In same order as they come). ```shell k8gb-coredns-5454ddd5b7-r555w coredns [INFO] plugin/wrr: [random][172.18.0.3 172.18.0.4 172.18.0.6 172.18.0.5] k8gb-coredns-5454ddd5b7-r555w coredns [INFO] plugin/wrr: [random][172.18.0.6 172.18.0.3 172.18.0.4 172.18.0.5] k8gb-coredns-5454ddd5b7-r555w coredns [INFO] plugin/wrr: [random][172.18.0.4 172.18.0.3 172.18.0.5 172.18.0.6] k8gb-coredns-5454ddd5b7-r555w coredns [INFO] plugin/wrr: [1 0][us1 eu1]: [172.18.0.5 172.18.0.6 172.18.0.3 172.18.0.4] k8gb-coredns-5454ddd5b7-r555w coredns [INFO] plugin/wrr: [0 1][eu1 us1]: [172.18.0.3 172.18.0.4 172.18.0.5 172.18.0.6] k8gb-coredns-5454ddd5b7-r555w coredns [INFO] plugin/wrr: [1 0][us1 eu1]: [172.18.0.5 172.18.0.6 172.18.0.4 172.18.0.3] k8gb-coredns-5454ddd5b7-r555w coredns [INFO] plugin/wrr: [random][172.18.0.6 172.18.0.3 172.18.0.5 172.18.0.4] k8gb-coredns-5454ddd5b7-r555w coredns [INFO] plugin/wrr: [random][172.18.0.6 172.18.0.5 172.18.0.3 172.18.0.4] k8gb-coredns-79458796bb-mq855 coredns [INFO] plugin/wrr: [skipping][172.18.0.5 172.18.0.6 172.18.0.3 172.18.0.4] k8gb-coredns-79458796bb-mq855 coredns [INFO] plugin/wrr: [skipping][172.18.0.5 172.18.0.6 172.18.0.3 172.18.0.4] k8gb-coredns-79458796bb-mq855 coredns [INFO] plugin/wrr: [skipping][172.18.0.5 172.18.0.6 172.18.0.3 172.18.0.4] k8gb-coredns-79458796bb-mq855 coredns [INFO] plugin/wrr: [1 0][us1 eu1]: [172.18.0.5 172.18.0.6 172.18.0.4 172.18.0.3] k8gb-coredns-79458796bb-mq855 coredns [INFO] plugin/wrr: [0 1][eu1 us1]: [172.18.0.3 172.18.0.4 172.18.0.5 172.18.0.6] ``` Signed-off-by: kuritka <kuritka@gmail.com>
related to k8gb-io/k8gb#50 there is difference between those three: ```yaml strategy: type: roundRobin splitBrainThresholdSeconds: 300 dnsTtlSeconds: 30 ``` ```yaml strategy: type: roundRobin splitBrainThresholdSeconds: 300 dnsTtlSeconds: 30 weight: eu: 1 us: 1 ``` ```yaml strategy: type: roundRobin splitBrainThresholdSeconds: 300 dnsTtlSeconds: 30 weight: eu: 1 ``` The difference is that first one provides standard coreDNS `loadbalance round_robin`(RRR) while second one enables WRR. The third one is incompleted. We cannot easily switch balancing in corefile to enable RRR and disable WRR when GSLB configuration has change. This PR contains functionality that switches between WRR, RRR and doing nothing (SKIP). I'm reusing CoreDNS loadbalance to perform RRR. ```shell k8gb-coredns-5454ddd5b7-r555w coredns [INFO] plugin/wrr: [random][172.18.0.3 172.18.0.4 172.18.0.6 172.18.0.5] k8gb-coredns-5454ddd5b7-r555w coredns [INFO] plugin/wrr: [random][172.18.0.6 172.18.0.3 172.18.0.4 172.18.0.5] k8gb-coredns-5454ddd5b7-r555w coredns [INFO] plugin/wrr: [random][172.18.0.4 172.18.0.3 172.18.0.5 172.18.0.6] k8gb-coredns-5454ddd5b7-r555w coredns [INFO] plugin/wrr: [1 0][us1 eu1]: [172.18.0.5 172.18.0.6 172.18.0.3 172.18.0.4] k8gb-coredns-5454ddd5b7-r555w coredns [INFO] plugin/wrr: [0 1][eu1 us1]: [172.18.0.3 172.18.0.4 172.18.0.5 172.18.0.6] k8gb-coredns-5454ddd5b7-r555w coredns [INFO] plugin/wrr: [1 0][us1 eu1]: [172.18.0.5 172.18.0.6 172.18.0.4 172.18.0.3] k8gb-coredns-79458796bb-mq855 coredns [INFO] plugin/wrr: [skipping][172.18.0.5 172.18.0.6 172.18.0.3 172.18.0.4] k8gb-coredns-79458796bb-mq855 coredns [INFO] plugin/wrr: [skipping][172.18.0.5 172.18.0.6 172.18.0.3 172.18.0.4] k8gb-coredns-79458796bb-mq855 coredns [INFO] plugin/wrr: [skipping][172.18.0.5 172.18.0.6 172.18.0.3 172.18.0.4] ``` Signed-off-by: kuritka <kuritka@gmail.com>
@kuritka as WRR is implemented, can we close this issue? |
Hi @ytsarev , sure we can. I supposed it's already closed |
WRR was released in https://github.com/k8gb-io/k8gb/releases/tag/v0.11.1. Closing |
As per the supported load balancing strategies in the initial design a weighted round robin strategy should be implemented to ensure the guarantees stated:
Scenario 1:
Deployment
with a backendService
calledapp
and that backend service exposed with aGslb
resource on cluster X as:and a
Gslb
resource on cluster Y as:When issuing the following command,
curl -v http://app.cloud.example.com
, I would expect the IP's resolved to reflect as follows (if this command was executed 6 times consecutively):The resolved node IP's that ingress traffic will be sent should be spread approximately according to the weighting configured on the
Glsb
resources. In this scenario that would be 80% (4 out of 6) resolved to cluster X and 20% (2 out of 6) resolved to cluster Y.NOTE:
Gslb
resources in 2 clusters have aweight
specified (that might or might not add up to 100%). How does that affect the distribution over 3 clusters?Deployment
s become unhealthy on a cluster, then the weighting should be adjusted to honour the weighting across the remaining clusters with healthyDeployment
sThe text was updated successfully, but these errors were encountered: