custom-routing-with-envoy: read routes from the routeserver HTTP API on 7778 - #75
Draft
scott-cotton wants to merge 1 commit into
Draft
custom-routing-with-envoy: read routes from the routeserver HTTP API on 7778#75scott-cotton wants to merge 1 commit into
scott-cotton wants to merge 1 commit into
Conversation
…on 7778 The lua filter fetched routes from the routeserver's legacy API on port 8080, /apis/apps/v1/namespaces/httpbin/deployments/httpbin/routes. That API is off by default in the next operator release and removed in the one after, so the filter now calls GET /api/v1/workloads/routing-rules on port 7778, passing the baseline workload and the routing key as query parameters. Two things get better in the move. The legacy response was an array that the operator omitted entirely when the baseline had no routes, and the filter indexed [1] into it unguarded -- a request carrying a routing key that matched no sandbox raised a lua error and returned 500 instead of falling through to baseline. And the legacy shape flattened every port mapping into one list, so the filter took whichever destination came first regardless of which port it belonged to; this pod has two container ports (httpbin 80, envoy 8080). The current API keeps the destinations grouped under workloadPort, so the filter selects port 80 -- the same port its baseline branch forwards to. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Why
The lua filter in
experimental/custom-routing-with-envoyfetches routes from the Route Server's legacy API on port 8080:That API predates the current Route Server. In the next operator release it stops serving by default — port 8080 answers
410 GoneunlessrouteServer.legacyRoutesAPI.enabledis set totrue— and it is removed in the release after that. So this example breaks out of the box on upgrade unless it moves.It is the last consumer of the legacy API in this repo; every other routeserver example (pub-sub, rabbitmq, temporal, SQS) already uses
:7778with/api/v1/workloads/routing-rules.What changed
The
signadot_routercluster now points at port 7778, and the filter calls the current HTTP API, passing the baseline workload and the routing key as query parameters:The response walk changes shape accordingly —
routingRules[] → mappings[] → destinations[], readinghost/portinstead of the legacy[1].routes[] → targetIP/targetPort.Two behaviors improve rather than just move:
A request with an unmatched routing key no longer 500s. The legacy endpoint returned an array that the operator omitted entirely when the baseline had no routes, and the filter indexed
parsed[1].routesinto it unguarded. A routing key matching no sandbox therefore raisedattempt to index a nil valuein the filter — a 500 — instead of falling through to baseline. Reproduced against the current filter with the bundledJSON.lua:The right port gets selected. The legacy response flattened every port mapping into a single list, so the filter took whichever destination came first regardless of which port it belonged to. This pod has two container ports — httpbin on 80 and the envoy sidecar on 8080 — so that choice was ordering-dependent. The current API keeps destinations grouped under
workloadPort, and the filter now selects 80, the same port its own baseline branch forwards to (127.0.0.1:80).Draft: needs a cluster run
The filter logic is checked, but end-to-end behavior against a live sandbox is not. What has been verified:
envoy.yamlparse; thesignadot_routercluster resolves to port 7778luaandluajitrequest_handleand the bundledJSON.lua: routes to the port-80 destination when a rule matches (choosing it over a port-8080 mapping listed first); falls through to baseline with no routing key, with{"routingRules":[]}, with{}, with a rule for a different key, and with a rule carrying no port-80 mappinghttpbin-test-sandbox— that the port-80 mapping is the one carrying the fork's reachable destination is read off the API's shape, not observedbaseline.png/forked.pngstill reflect what the walkthrough producesMarking draft until someone can run the walkthrough in the README.