feat: supoort kruise custom api for gateway #278
feat: supoort kruise custom api for gateway #278furykerry merged 8 commits intoopenkruise:masterfrom
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #278 +/- ##
==========================================
+ Coverage 70.74% 72.12% +1.38%
==========================================
Files 116 116
Lines 10643 8657 -1986
==========================================
- Hits 7529 6244 -1285
+ Misses 2810 2104 -706
- Partials 304 309 +5
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
7695a53 to
3702315
Compare
|
/assign @furykerry @AiRanthem |
Signed-off-by: xianying.czy <xianying.czy@alibaba-inc.com>
- Update e2e workflows to build and load sandbox-gateway docker image - Add deployment and undeployment of sandbox-gateway in makefile targets - Include sandbox-gateway environment variable in workflows - Ensure sandbox-gateway image is loaded into Kind cluster for testing - Improve completeness of sandbox-gateway continuous integration process
Signed-off-by: xianying.czy <xianying.czy@alibaba-inc.com>
Signed-off-by: xianying.czy <xianying.czy@alibaba-inc.com>
787114e to
4ba48e4
Compare
Signed-off-by: xianying.czy <xianying.czy@alibaba-inc.com>
Signed-off-by: xianying.czy <xianying.czy@alibaba-inc.com>
48ce1b1 to
965e4d4
Compare
Signed-off-by: xianying.czy <xianying.czy@alibaba-inc.com>
Signed-off-by: xianying.czy <xianying.czy@alibaba-inc.com>
c877768 to
9fb14dd
Compare
| func (a *CustomizedE2BAdapter) Map(_, _, path string, _ int, _ map[string]string) ( | ||
| func (a *CustomizedE2BAdapter) Map(req *ParsedRequest) ( | ||
| sandboxID string, sandboxPort int, extraHeaders map[string]string, err error) { | ||
| path := req.Path |
There was a problem hiding this comment.
Request Changes: There is a parsing bug when a private protocol URL has no trailing path. URLs like /kruise/sandbox-foo/8080 fail to parse, while /kruise/sandbox-foo/8080/some-path works correctly. The root cause appears to be the handling of the trailing / delimiter — the parser assumes a path component always exists. Please fix the URL parsing logic to correctly handle the case where no path is present.
| authority := req.Authority | ||
| headers := req.Headers | ||
|
|
||
| // Step 1: Header-based extraction (primary) |
There was a problem hiding this comment.
Suggestion: Consider splitting the current logic into two separate functions — one for parsing the header and one for parsing the host. When the header parsing returns an error, the code can fall back to the host parsing logic. This separation would make the flow clearer and easier to maintain going forward.
Now let me also check the earlier part of the diff that was truncated:
Here's the generated PR description:
Ⅰ. Describe what this PR does
This PR adds support for the Kruise custom API protocol in the sandbox-gateway, refactoring the filter to use a unified adapter pattern for sandbox routing.
Gateway filter refactoring (
pkg/sandbox-gateway/filter/)DecodeHeaderswith the unifiedE2BMapperadapter interface frompkg/servers/e2b/adapters/FilterConfigwrapper that holds bothConfigandAdapter, created viaNewFilterConfig()/NewE2BAdapterWithOptions()ExtractHostInfo()fromConfig— host parsing is now delegated toNativeE2BAdapterintthroughout the filter instead ofstring:pathrewrite for kruise custom protocol)NativeE2BAdapter enhancements (
pkg/servers/e2b/adapters/native_e2b.go)NativeE2BAdapterwith configurable fields:SandboxIDHeader,SandboxPortHeader,HostHeader,DefaultPortNewE2BAdapterWithOptions()constructor for the gateway use caseEnvoy configuration (
config/sandbox-gateway/configmap.yaml)/kruise/apiroute prefix that forwards to a newmanager_cluster(sandbox-manager service on port 7788)Deployment cleanup (
config/sandbox-gateway/deployment.yaml)init-sysctlinit container that requiredSYS_ADMINcapabilitiesCI & E2E (
hack/,.github/workflows/,test/e2b/)run-e2b-e2e-test.shto wait for gateway pods and port-forward through gateway instead of manager directlytest_gateway.pywith header-based and host-based routing e2e testsMakefile
deploy-sandbox-gatewayandundeploy-sandbox-gatewaytargetsⅡ. Does this pull request fix one issue?
NONE
Ⅲ. Describe how to verify it
test/e2b/test_gateway.pyvalidates both header-based and host-based routing through the gateway.e2b-sandbox-idande2b-sandbox-portheaders → should route to the correct sandbox pod{port}-{ns}--{name}.example.com→ should route via hostname fallback/kruise/ns--sandbox/3000/api/v1/data→ should route via kruise custom protocol with path rewriteⅣ. Special notes for reviews
init-sysctlinit container withSYS_ADMINcapability was removed from the gateway deployment — verify this is acceptable for your environment.NativeE2BAdapter.Map()signature is unchanged but the behavior now supports header-first extraction. Existing callers using only hostname-based routing are unaffected (hostname fallback still works).ConfigParser.MergeandFilterFactorynow operate on*FilterConfiginstead of*Config— this is a breaking change for the internal Envoy Go filter API surface but not for external consumers.