Skip to content

Commit

Permalink
EndpointSlice to IR Route Destinations (#1494)
Browse files Browse the repository at this point in the history
* EndpointSlice to IR Route Destinations

Relates to #1256

Signed-off-by: Arko Dasgupta <[email protected]>

* assign backend weight to locality weight

add another level of indirection in RouteDestination
called DestinationSetting

Signed-off-by: Arko Dasgupta <[email protected]>
  • Loading branch information
arkodg authored Sep 26, 2023
1 parent c70144b commit a785be8
Show file tree
Hide file tree
Showing 256 changed files with 2,006 additions and 1,165 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ staticResources:
loadAssignment:
clusterName: xds_cluster
endpoints:
- lbEndpoints:
- endpoint:
- loadBalancingWeight: 1
lbEndpoints:
- loadBalancingWeight: 1
endpoint:
address:
socketAddress:
address: envoy-gateway
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,11 @@
"portValue": 18000
}
}
}
},
"loadBalancingWeight": 1
}
]
],
"loadBalancingWeight": 1
}
]
},
Expand Down Expand Up @@ -261,7 +263,8 @@
"portValue": 443
}
}
}
},
"loadBalancingWeight": 1
}
],
"loadBalancingWeight": 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ xds:
socketAddress:
address: envoy-gateway
portValue: 18000
loadBalancingWeight: 1
loadBalancingWeight: 1
name: xds_cluster
transportSocket:
name: envoy.transport_sockets.tls
Expand Down Expand Up @@ -153,6 +155,7 @@ xds:
socketAddress:
address: raw.githubusercontent.com
portValue: 443
loadBalancingWeight: 1
loadBalancingWeight: 1
locality: {}
name: raw_githubusercontent_com_443
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ xds:
socketAddress:
address: envoy-gateway
portValue: 18000
loadBalancingWeight: 1
loadBalancingWeight: 1
name: xds_cluster
transportSocket:
name: envoy.transport_sockets.tls
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ xds:
socketAddress:
address: raw.githubusercontent.com
portValue: 443
loadBalancingWeight: 1
loadBalancingWeight: 1
locality: {}
name: raw_githubusercontent_com_443
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,10 @@ envoyProxy:
load_assignment:
cluster_name: xds_cluster
endpoints:
- lb_endpoints:
- endpoint:
- load_balancing_weight: 1
lb_endpoints:
- load_balancing_weight: 1
endpoint:
address:
socket_address:
address: envoy-gateway
Expand Down Expand Up @@ -479,6 +481,8 @@ xds:
socketAddress:
address: envoy-gateway
portValue: 18000
loadBalancingWeight: 1
loadBalancingWeight: 1
name: xds_cluster
transportSocket:
name: envoy.transport_sockets.tls
Expand Down Expand Up @@ -582,6 +586,7 @@ xds:
socketAddress:
address: 127.0.0.1
portValue: 3000
loadBalancingWeight: 1
loadBalancingWeight: 1
locality: {}
- endpointConfig:
Expand All @@ -594,6 +599,7 @@ xds:
socketAddress:
address: 127.0.0.1
portValue: 3000
loadBalancingWeight: 1
loadBalancingWeight: 1
locality: {}
- '@type': type.googleapis.com/envoy.admin.v3.ClustersConfigDump
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ xds:
socketAddress:
address: envoy-gateway
portValue: 18000
loadBalancingWeight: 1
loadBalancingWeight: 1
name: xds_cluster
transportSocket:
name: envoy.transport_sockets.tls
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,11 @@
"portValue": 18000
}
}
}
},
"loadBalancingWeight": 1
}
]
],
"loadBalancingWeight": 1
}
]
},
Expand Down Expand Up @@ -276,7 +278,8 @@
"portValue": 3000
}
}
}
},
"loadBalancingWeight": 1
}
],
"loadBalancingWeight": 1,
Expand All @@ -300,7 +303,8 @@
"portValue": 3000
}
}
}
},
"loadBalancingWeight": 1
}
],
"loadBalancingWeight": 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ xds:
socketAddress:
address: envoy-gateway
portValue: 18000
loadBalancingWeight: 1
loadBalancingWeight: 1
name: xds_cluster
transportSocket:
name: envoy.transport_sockets.tls
Expand Down Expand Up @@ -154,6 +156,7 @@ xds:
socketAddress:
address: 1.1.1.1
portValue: 3000
loadBalancingWeight: 1
loadBalancingWeight: 1
locality: {}
- endpointConfig:
Expand All @@ -166,6 +169,7 @@ xds:
socketAddress:
address: 1.1.1.1
portValue: 3000
loadBalancingWeight: 1
loadBalancingWeight: 1
locality: {}
- '@type': type.googleapis.com/envoy.admin.v3.ClustersConfigDump
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ xds:
socketAddress:
address: envoy-gateway
portValue: 18000
loadBalancingWeight: 1
loadBalancingWeight: 1
name: xds_cluster
transportSocket:
name: envoy.transport_sockets.tls
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ xds:
socketAddress:
address: 1.1.1.1
portValue: 3000
loadBalancingWeight: 1
loadBalancingWeight: 1
locality: {}
- endpointConfig:
Expand All @@ -63,5 +64,6 @@ xds:
socketAddress:
address: 1.1.1.1
portValue: 3000
loadBalancingWeight: 1
loadBalancingWeight: 1
locality: {}
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,11 @@
"portValue": 18000
}
}
}
},
"loadBalancingWeight": 1
}
]
],
"loadBalancingWeight": 1
}
]
},
Expand Down Expand Up @@ -261,7 +263,8 @@
"portValue": 8081
}
}
}
},
"loadBalancingWeight": 1
}
],
"loadBalancingWeight": 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ xds:
socketAddress:
address: envoy-gateway
portValue: 18000
loadBalancingWeight: 1
loadBalancingWeight: 1
name: xds_cluster
transportSocket:
name: envoy.transport_sockets.tls
Expand Down Expand Up @@ -153,6 +155,7 @@ xds:
socketAddress:
address: envoy-ratelimit.envoy-gateway.svc.cluster.local
portValue: 8081
loadBalancingWeight: 1
loadBalancingWeight: 1
locality: {}
name: ratelimit_cluster
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ xds:
socketAddress:
address: envoy-gateway
portValue: 18000
loadBalancingWeight: 1
loadBalancingWeight: 1
name: xds_cluster
transportSocket:
name: envoy.transport_sockets.tls
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ xds:
socketAddress:
address: envoy-ratelimit.envoy-gateway.svc.cluster.local
portValue: 8081
loadBalancingWeight: 1
loadBalancingWeight: 1
locality: {}
name: ratelimit_cluster
Expand Down
14 changes: 8 additions & 6 deletions internal/cmd/egctl/translate.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,10 @@ func translateGatewayAPIToGatewayAPI(resources *gatewayapi.Resources) (gatewayap

// Translate from Gateway API to Xds IR
gTranslator := &gatewayapi.Translator{
GatewayControllerName: egv1alpha1.GatewayControllerName,
GatewayClassName: v1beta1.ObjectName(resources.GatewayClass.Name),
GlobalRateLimitEnabled: true,
GatewayControllerName: egv1alpha1.GatewayControllerName,
GatewayClassName: v1beta1.ObjectName(resources.GatewayClass.Name),
GlobalRateLimitEnabled: true,
EndpointRoutingDisabled: true,
}
gRes := gTranslator.Translate(resources)
// Update the status of the GatewayClass based on EnvoyProxy validation
Expand Down Expand Up @@ -292,9 +293,10 @@ func translateGatewayAPIToXds(dnsDomain string, resourceType string, resources *

// Translate from Gateway API to Xds IR
gTranslator := &gatewayapi.Translator{
GatewayControllerName: egv1alpha1.GatewayControllerName,
GatewayClassName: v1beta1.ObjectName(resources.GatewayClass.Name),
GlobalRateLimitEnabled: true,
GatewayControllerName: egv1alpha1.GatewayControllerName,
GatewayClassName: v1beta1.ObjectName(resources.GatewayClass.Name),
GlobalRateLimitEnabled: true,
EndpointRoutingDisabled: true,
}
gRes := gTranslator.Translate(resources)

Expand Down
6 changes: 3 additions & 3 deletions internal/gatewayapi/filters.go
Original file line number Diff line number Diff line change
Expand Up @@ -833,11 +833,11 @@ func (t *Translator) processRequestMirrorFilter(
return
}

mirrorEndpoints, _ := t.processDestEndpoints(mirrorBackendRef, filterContext.ParentRef, filterContext.Route, resources)
ds, _ := t.processDestination(mirrorBackendRef, filterContext.ParentRef, filterContext.Route, resources)

newMirror := &ir.RouteDestination{
Name: fmt.Sprintf("%s-mirror-%d", irRouteDestinationName(filterContext.Route, filterContext.RuleIdx), filterIdx),
Endpoints: mirrorEndpoints,
Name: fmt.Sprintf("%s-mirror-%d", irRouteDestinationName(filterContext.Route, filterContext.RuleIdx), filterIdx),
Settings: []*ir.DestinationSetting{ds},
}
filterContext.Mirrors = append(filterContext.Mirrors, newMirror)
}
Expand Down
20 changes: 0 additions & 20 deletions internal/gatewayapi/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,6 @@ func SectionNamePtr(name string) *v1beta1.SectionName {
return &sectionName
}

func TLSModeTypePtr(mode v1beta1.TLSModeType) *v1beta1.TLSModeType {
return &mode
}

func StringPtr(val string) *string {
return &val
}

func Int32Ptr(val int32) *int32 {
return &val
}

func PortNumPtr(val int32) *v1beta1.PortNumber {
portNum := v1beta1.PortNumber(val)
return &portNum
Expand All @@ -79,14 +67,6 @@ func ObjectNamePtr(val string) *v1alpha2.ObjectName {
return &objectName
}

func PathMatchTypePtr(pType v1beta1.PathMatchType) *v1beta1.PathMatchType {
return &pType
}

func GatewayAddressTypePtr(addr v1beta1.AddressType) *v1beta1.AddressType {
return &addr
}

func PathMatchTypeDerefOr(matchType *v1beta1.PathMatchType, defaultType v1beta1.PathMatchType) v1beta1.PathMatchType {
if matchType != nil {
return *matchType
Expand Down
11 changes: 11 additions & 0 deletions internal/gatewayapi/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,14 @@ func (r *Resources) GetSecret(namespace, name string) *v1.Secret {

return nil
}

func (r *Resources) GetEndpointSlicesForService(svcNamespace, svcName string) []*discoveryv1.EndpointSlice {
endpointSlices := []*discoveryv1.EndpointSlice{}
for _, endpointSlice := range r.EndpointSlices {
if svcNamespace == endpointSlice.Namespace &&
endpointSlice.GetLabels()[discoveryv1.LabelServiceName] == svcName {
endpointSlices = append(endpointSlices, endpointSlice)
}
}
return endpointSlices
}
Loading

0 comments on commit a785be8

Please sign in to comment.