-
Notifications
You must be signed in to change notification settings - Fork 397
feature: zone aware routing - Option 1 #3117
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
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
05bd589
feature: zone aware eskip.LBEndpoints
szuecs d5d1636
- add zone specific fields to eskipBytes
greeshma1196 49edce2
- fix basic test - add zone context to output from dataclient
greeshma1196 741b130
- update logic in dataclient - only add zone information to LBEndpoin…
greeshma1196 8bc2c62
- update targetsByServicePort() to return both zoneAware endpoints an…
greeshma1196 025564d
- fix shortcheck test - remove zone info in testFixture so that the e…
greeshma1196 64b0617
- refactor dataclient
greeshma1196 3d914e4
- address feedback
greeshma1196 060ee6f
- address shortcheck error
greeshma1196 3712ef9
- add KubernetesTopologyZone to config
greeshma1196 3a72be5
- Remove zone filtering from dataclient - return all endpoints with z…
greeshma1196 8d363d7
nop: move emptyline
szuecs 1494923
- add newline
greeshma1196 91aa7cc
- [x] Modify GetEndpointSlicesByService and GetEndpointSlicesByTarget to
greeshma1196 2da06da
refactor: renew Go
szuecs 429f434
test valkey endpoints
szuecs d612d3a
fix: vet finding
szuecs 6d50253
- address feedback
greeshma1196 6d88c57
- address check-fmt error
greeshma1196 37c97e9
- address feedback
greeshma1196 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -82,11 +82,14 @@ func convertPathRuleV1( | |
| } | ||
|
|
||
| var ( | ||
| eps []string | ||
| err error | ||
| svc *service | ||
| eps []string | ||
| epSlices []skipperEndpoint | ||
| err error | ||
| svc *service | ||
| ) | ||
|
|
||
| dataclientZone := ic.zone | ||
|
|
||
| var hostRegexp []string | ||
| if host != "" { | ||
| hostRegexp = []string{createHostRx(host)} | ||
|
|
@@ -121,7 +124,14 @@ func convertPathRuleV1( | |
| protocol = p | ||
| } | ||
|
|
||
| eps = state.GetEndpointsByService(ic.zone, ns, svcName, protocol, servicePort) | ||
| if state.enableEndpointSlices { | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Kubernetes deprecated endpoints in favor of endpointslices and we used this switch only to enable it when it was more recent. |
||
| epSlices = state.GetEndpointSlicesByService(dataclientZone, ns, svcName, protocol, servicePort) | ||
| for _, ep := range epSlices { | ||
|
MustafaSaber marked this conversation as resolved.
|
||
| eps = append(eps, ep.Address) | ||
| } | ||
| } else { | ||
| eps = state.GetEndpointsByService(ns, svcName, protocol, servicePort) | ||
| } | ||
| } | ||
| if len(eps) == 0 { | ||
| ic.logger.Tracef("Target endpoints not found, shuntroute for %s:%s", svcName, svcPort) | ||
|
|
@@ -138,6 +148,7 @@ func convertPathRuleV1( | |
| } | ||
|
|
||
| ic.logger.Tracef("Found %d endpoints for %s:%s", len(eps), svcName, svcPort) | ||
|
|
||
| if len(eps) == 1 { | ||
| r := &eskip.Route{ | ||
| Id: routeID(ns, name, host, prule.Path, svcName), | ||
|
|
@@ -154,10 +165,20 @@ func convertPathRuleV1( | |
| r := &eskip.Route{ | ||
| Id: routeID(ns, name, host, prule.Path, svcName), | ||
| BackendType: eskip.LBBackend, | ||
| LBEndpoints: eps, | ||
| LBAlgorithm: getLoadBalancerAlgorithm(metadata, defaultLoadBalancerAlgorithm), | ||
| HostRegexps: hostRegexp, | ||
| } | ||
|
|
||
| if state.enableEndpointSlices { | ||
| var lbeps []*eskip.LBEndpoint | ||
| for _, ep := range epSlices { | ||
| lbeps = append(lbeps, &eskip.LBEndpoint{Address: ep.Address, Zone: ep.Zone}) | ||
| } | ||
| r.LBEndpoints = lbeps | ||
| } else { | ||
| r.LBEndpoints = eskip.NewLBEndpoints(eps) | ||
| } | ||
|
|
||
| setPathV1(pathMode, r, prule.PathType, prule.Path) | ||
| traffic.apply(r) | ||
| return r, nil | ||
|
|
@@ -348,14 +369,17 @@ func (ing *ingress) convertDefaultBackendV1( | |
| } | ||
|
|
||
| var ( | ||
| eps []string | ||
| err error | ||
| ns = i.Metadata.Namespace | ||
| name = i.Metadata.Name | ||
| svcName = i.Spec.DefaultBackend.Service.Name | ||
| svcPort = i.Spec.DefaultBackend.Service.Port | ||
| eps []string | ||
| epSlices []skipperEndpoint | ||
| err error | ||
| ns = i.Metadata.Namespace | ||
| name = i.Metadata.Name | ||
| svcName = i.Spec.DefaultBackend.Service.Name | ||
| svcPort = i.Spec.DefaultBackend.Service.Port | ||
| ) | ||
|
|
||
| dataclientZone := ic.zone | ||
|
|
||
| svc, err := state.getService(ns, svcName) | ||
| if err != nil { | ||
| ic.logger.Errorf("Failed to get service %s, %s", svcName, svcPort) | ||
|
|
@@ -382,14 +406,20 @@ func (ing *ingress) convertDefaultBackendV1( | |
| protocol = p | ||
| } | ||
|
|
||
| eps = state.GetEndpointsByService( | ||
| ing.zone, | ||
| ns, | ||
| svcName, | ||
| protocol, | ||
| servicePort, | ||
| ) | ||
| ic.logger.Debugf("Found %d endpoints for %s: %v", len(eps), svcName, err) | ||
| if state.enableEndpointSlices { | ||
| epSlices = state.GetEndpointSlicesByService(dataclientZone, ns, svcName, protocol, servicePort) | ||
| for _, ep := range epSlices { | ||
| eps = append(eps, ep.Address) | ||
| } | ||
| } else { | ||
| eps = state.GetEndpointsByService( | ||
| ns, | ||
| svcName, | ||
| protocol, | ||
| servicePort, | ||
| ) | ||
| ic.logger.Debugf("Found %d endpoints for %s: %v", len(eps), svcName, err) | ||
| } | ||
| } | ||
|
|
||
| if len(eps) == 0 { | ||
|
|
@@ -408,12 +438,23 @@ func (ing *ingress) convertDefaultBackendV1( | |
| }, true, nil | ||
| } | ||
|
|
||
| return &eskip.Route{ | ||
| r := &eskip.Route{ | ||
| Id: routeID(ns, name, "", "", ""), | ||
| BackendType: eskip.LBBackend, | ||
| LBEndpoints: eps, | ||
| LBAlgorithm: getLoadBalancerAlgorithm(i.Metadata, ing.defaultLoadBalancerAlgorithm), | ||
| }, true, nil | ||
| } | ||
|
|
||
| if state.enableEndpointSlices { | ||
| var lbeps []*eskip.LBEndpoint | ||
| for _, ep := range epSlices { | ||
| lbeps = append(lbeps, &eskip.LBEndpoint{Address: ep.Address, Zone: ep.Zone}) | ||
| } | ||
| r.LBEndpoints = lbeps | ||
| } else { | ||
| r.LBEndpoints = eskip.NewLBEndpoints(eps) | ||
| } | ||
|
|
||
| return r, true, nil | ||
| } | ||
|
|
||
| func serviceNameBackend(svcName, svcNamespace string, servicePort *servicePort) string { | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.