Skip to content

Commit 6be1747

Browse files
authored
feat: Implement ZoneAware loadbalancing - Use non-static local_cluster name (splitup #6482) (#6497)
* Use non-staic local_cluster name Signed-off-by: Jukie <[email protected]> * Pass as bootstrap value Signed-off-by: jukie <[email protected]>
1 parent 2504990 commit 6be1747

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+150
-134
lines changed

internal/infrastructure/common/proxy_args.go

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ package common
88
import (
99
"fmt"
1010

11+
"k8s.io/utils/ptr"
12+
1113
egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1"
1214
"github.com/envoyproxy/gateway/internal/ir"
1315
"github.com/envoyproxy/gateway/internal/xds/bootstrap"
@@ -29,9 +31,19 @@ func BuildProxyArgs(
2931
serviceNode string,
3032
gatewayNamespaceMode bool,
3133
) ([]string, error) {
32-
// If IPFamily is not set, try to determine it from the infrastructure.
33-
if bootstrapConfigOptions != nil && bootstrapConfigOptions.IPFamily == nil {
34-
bootstrapConfigOptions.IPFamily = getIPFamily(infra)
34+
serviceCluster := infra.Name
35+
if gatewayNamespaceMode {
36+
serviceCluster = fmt.Sprintf("%s/%s", infra.Namespace, infra.Name)
37+
}
38+
39+
if bootstrapConfigOptions != nil {
40+
// Configure local Envoy ServiceCluster
41+
bootstrapConfigOptions.ServiceClusterName = ptr.To(serviceCluster)
42+
43+
// If IPFamily is not set, try to determine it from the infrastructure.
44+
if bootstrapConfigOptions.IPFamily == nil {
45+
bootstrapConfigOptions.IPFamily = getIPFamily(infra)
46+
}
3547
}
3648

3749
bootstrapConfigOptions.GatewayNamespaceMode = gatewayNamespaceMode
@@ -51,11 +63,6 @@ func BuildProxyArgs(
5163

5264
logging := infra.Config.Spec.Logging
5365

54-
serviceCluster := infra.Name
55-
if gatewayNamespaceMode {
56-
serviceCluster = fmt.Sprintf("%s/%s", infra.Namespace, infra.Name)
57-
}
58-
5966
args := []string{
6067
fmt.Sprintf("--service-cluster %s", serviceCluster),
6168
fmt.Sprintf("--service-node %s", serviceNode),

internal/infrastructure/kubernetes/proxy/testdata/daemonsets/custom.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ spec:
5555
address: 127.0.0.1
5656
port_value: 19000
5757
cluster_manager:
58-
local_cluster_name: local_cluster
58+
local_cluster_name: default
5959
node:
6060
locality:
6161
zone: $(ENVOY_SERVICE_ZONE)
@@ -132,7 +132,7 @@ spec:
132132
- connect_timeout: 10s
133133
lb_policy: ROUND_ROBIN
134134
load_assignment:
135-
cluster_name: local_cluster
135+
cluster_name: default
136136
endpoints:
137137
- lb_endpoints:
138138
- endpoint:
@@ -144,7 +144,7 @@ spec:
144144
load_balancing_weight: 1
145145
locality:
146146
zone: $(ENVOY_SERVICE_ZONE)
147-
name: local_cluster
147+
name: default
148148
type: STATIC
149149
- connect_timeout: 10s
150150
load_assignment:

internal/infrastructure/kubernetes/proxy/testdata/daemonsets/default-env.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ spec:
5454
address: 127.0.0.1
5555
port_value: 19000
5656
cluster_manager:
57-
local_cluster_name: local_cluster
57+
local_cluster_name: default
5858
node:
5959
locality:
6060
zone: $(ENVOY_SERVICE_ZONE)
@@ -131,7 +131,7 @@ spec:
131131
- connect_timeout: 10s
132132
lb_policy: ROUND_ROBIN
133133
load_assignment:
134-
cluster_name: local_cluster
134+
cluster_name: default
135135
endpoints:
136136
- lb_endpoints:
137137
- endpoint:
@@ -143,7 +143,7 @@ spec:
143143
load_balancing_weight: 1
144144
locality:
145145
zone: $(ENVOY_SERVICE_ZONE)
146-
name: local_cluster
146+
name: default
147147
type: STATIC
148148
- connect_timeout: 10s
149149
load_assignment:

internal/infrastructure/kubernetes/proxy/testdata/daemonsets/default.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ spec:
5454
address: 127.0.0.1
5555
port_value: 19000
5656
cluster_manager:
57-
local_cluster_name: local_cluster
57+
local_cluster_name: default
5858
node:
5959
locality:
6060
zone: $(ENVOY_SERVICE_ZONE)
@@ -131,7 +131,7 @@ spec:
131131
- connect_timeout: 10s
132132
lb_policy: ROUND_ROBIN
133133
load_assignment:
134-
cluster_name: local_cluster
134+
cluster_name: default
135135
endpoints:
136136
- lb_endpoints:
137137
- endpoint:
@@ -143,7 +143,7 @@ spec:
143143
load_balancing_weight: 1
144144
locality:
145145
zone: $(ENVOY_SERVICE_ZONE)
146-
name: local_cluster
146+
name: default
147147
type: STATIC
148148
- connect_timeout: 10s
149149
load_assignment:

internal/infrastructure/kubernetes/proxy/testdata/daemonsets/disable-prometheus.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ spec:
5050
address: 127.0.0.1
5151
port_value: 19000
5252
cluster_manager:
53-
local_cluster_name: local_cluster
53+
local_cluster_name: default
5454
node:
5555
locality:
5656
zone: $(ENVOY_SERVICE_ZONE)
@@ -80,7 +80,7 @@ spec:
8080
- connect_timeout: 10s
8181
lb_policy: ROUND_ROBIN
8282
load_assignment:
83-
cluster_name: local_cluster
83+
cluster_name: default
8484
endpoints:
8585
- lb_endpoints:
8686
- endpoint:
@@ -92,7 +92,7 @@ spec:
9292
load_balancing_weight: 1
9393
locality:
9494
zone: $(ENVOY_SERVICE_ZONE)
95-
name: local_cluster
95+
name: default
9696
type: STATIC
9797
- connect_timeout: 10s
9898
load_assignment:

internal/infrastructure/kubernetes/proxy/testdata/daemonsets/extension-env.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ spec:
5454
address: 127.0.0.1
5555
port_value: 19000
5656
cluster_manager:
57-
local_cluster_name: local_cluster
57+
local_cluster_name: default
5858
node:
5959
locality:
6060
zone: $(ENVOY_SERVICE_ZONE)
@@ -131,7 +131,7 @@ spec:
131131
- connect_timeout: 10s
132132
lb_policy: ROUND_ROBIN
133133
load_assignment:
134-
cluster_name: local_cluster
134+
cluster_name: default
135135
endpoints:
136136
- lb_endpoints:
137137
- endpoint:
@@ -143,7 +143,7 @@ spec:
143143
load_balancing_weight: 1
144144
locality:
145145
zone: $(ENVOY_SERVICE_ZONE)
146-
name: local_cluster
146+
name: default
147147
type: STATIC
148148
- connect_timeout: 10s
149149
load_assignment:

internal/infrastructure/kubernetes/proxy/testdata/daemonsets/gateway-namespace-mode.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ spec:
5757
address: 127.0.0.1
5858
port_value: 19000
5959
cluster_manager:
60-
local_cluster_name: local_cluster
60+
local_cluster_name: ns1/gateway-1
6161
node:
6262
locality:
6363
zone: $(ENVOY_SERVICE_ZONE)
@@ -134,7 +134,7 @@ spec:
134134
- connect_timeout: 10s
135135
lb_policy: ROUND_ROBIN
136136
load_assignment:
137-
cluster_name: local_cluster
137+
cluster_name: ns1/gateway-1
138138
endpoints:
139139
- lb_endpoints:
140140
- endpoint:
@@ -146,7 +146,7 @@ spec:
146146
load_balancing_weight: 1
147147
locality:
148148
zone: $(ENVOY_SERVICE_ZONE)
149-
name: local_cluster
149+
name: ns1/gateway-1
150150
type: STATIC
151151
- connect_timeout: 10s
152152
load_assignment:

internal/infrastructure/kubernetes/proxy/testdata/daemonsets/override-labels-and-annotations.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ spec:
6363
address: 127.0.0.1
6464
port_value: 19000
6565
cluster_manager:
66-
local_cluster_name: local_cluster
66+
local_cluster_name: default
6767
node:
6868
locality:
6969
zone: $(ENVOY_SERVICE_ZONE)
@@ -140,7 +140,7 @@ spec:
140140
- connect_timeout: 10s
141141
lb_policy: ROUND_ROBIN
142142
load_assignment:
143-
cluster_name: local_cluster
143+
cluster_name: default
144144
endpoints:
145145
- lb_endpoints:
146146
- endpoint:
@@ -152,7 +152,7 @@ spec:
152152
load_balancing_weight: 1
153153
locality:
154154
zone: $(ENVOY_SERVICE_ZONE)
155-
name: local_cluster
155+
name: default
156156
type: STATIC
157157
- connect_timeout: 10s
158158
load_assignment:

internal/infrastructure/kubernetes/proxy/testdata/daemonsets/override-prometheus-annotations.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ spec:
5454
address: 127.0.0.1
5555
port_value: 19000
5656
cluster_manager:
57-
local_cluster_name: local_cluster
57+
local_cluster_name: default
5858
node:
5959
locality:
6060
zone: $(ENVOY_SERVICE_ZONE)
@@ -131,7 +131,7 @@ spec:
131131
- connect_timeout: 10s
132132
lb_policy: ROUND_ROBIN
133133
load_assignment:
134-
cluster_name: local_cluster
134+
cluster_name: default
135135
endpoints:
136136
- lb_endpoints:
137137
- endpoint:
@@ -143,7 +143,7 @@ spec:
143143
load_balancing_weight: 1
144144
locality:
145145
zone: $(ENVOY_SERVICE_ZONE)
146-
name: local_cluster
146+
name: default
147147
type: STATIC
148148
- connect_timeout: 10s
149149
load_assignment:

internal/infrastructure/kubernetes/proxy/testdata/daemonsets/patch-daemonset.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ spec:
5454
address: 127.0.0.1
5555
port_value: 19000
5656
cluster_manager:
57-
local_cluster_name: local_cluster
57+
local_cluster_name: default
5858
node:
5959
locality:
6060
zone: $(ENVOY_SERVICE_ZONE)
@@ -131,7 +131,7 @@ spec:
131131
- connect_timeout: 10s
132132
lb_policy: ROUND_ROBIN
133133
load_assignment:
134-
cluster_name: local_cluster
134+
cluster_name: default
135135
endpoints:
136136
- lb_endpoints:
137137
- endpoint:
@@ -143,7 +143,7 @@ spec:
143143
load_balancing_weight: 1
144144
locality:
145145
zone: $(ENVOY_SERVICE_ZONE)
146-
name: local_cluster
146+
name: default
147147
type: STATIC
148148
- connect_timeout: 10s
149149
load_assignment:

0 commit comments

Comments
 (0)