Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EndpointSlice to IR Route Destinations #1494

Merged
merged 13 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand that we want the routing behavior to be backward compatible, but I think using endpoints as default to route traffic allows EG to bypass kube-proxy's overhead and fully leverage Envoy's advanced capabilities: more LB algorithms, session sticky, etc.

Copy link
Contributor Author

@arkodg arkodg Sep 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have disabled this in egctl x translate, because if we enable it, it will be mandatory, and all translations will fail if EndpointSlice is not provided by the user, this config is usually generated by k8s and is not part of user config, I was planning on raising a separate GH issue on dealing with this convenience / correctness dilemma

}
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
Loading