feat(gateway-operator): add per-operation upstream override to the RestApi CRD#2834
Draft
mehara-rothila wants to merge 1 commit into
Draft
feat(gateway-operator): add per-operation upstream override to the RestApi CRD#2834mehara-rothila wants to merge 1 commit into
mehara-rothila wants to merge 1 commit into
Conversation
Adds operations[].upstream to the RestApi CRD so an operation can reference a named upstreamDefinitions entry (main/sandbox), mirroring the platform-api per-operation override. The field is added identically to v1 and v1alpha1 to keep the served-version schemas identical, with regenerated deepcopy and CRD manifest and a payload test covering ref emission.
Contributor
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Purpose
Add per-operation upstream overrides to the gateway-operator's
RestApiCRD, so an individual operation can route to a different backend by referencing a named entry in the API'supstreamDefinitionspool. This is the operator-side counterpart of the same feature on the other two planes: the platform-api control plane (PR #2155) and the gateway-controller data plane (PR #2012). The operator's CRD already carried theupstreamDefinitionspool and the API-levelupstream.ref, but itsOperationtype had no per-operation upstream field, so this closes that gap and brings the CRD surface to parity with the platform-api.Approach
Operationgains an optionalupstreamoverride whosemain/sandboxeach reference a pool entry by name (refonly, no inline URLs), mirroring the platform-apiOperationUpstreamshape.refis required within each block, and a CEL validation (x-kubernetes-validations) requires at least one ofmainorsandbox.api/v1(storage) andapi/v1alpha1(served). The two versions use conversion strategyNone(a plain JSON round-trip that only works while the schemas are identical), andTestCRDVersionSchemasIdenticalenforces that invariant, so the field must be mirrored in both.json.Marshal, so the new field flows to the gateway automatically through its json tags. The gateway-controller then enforces and routes it (PR Add per-operation upstream override for REST API operations #2012).zz_generated.deepcopy.go(both versions) and theRestApiCRD manifest were regenerated with the pinnedcontroller-gen v0.16.5.Example
A
RestApiwith a reusable pool, an API-level default upstream, and one operation overridden to a pool entry:Testing
TestCRDVersionSchemasIdenticaland the v1alpha1 to v1 conversion round-trip tests pass, confirming the two served versions stay schema-identical with the new field.TestBuildRestAPIYAML_CarriesPerOperationUpstreamRef) verifies thatoperations[].upstream.main.refsurvives into the emitted management-API YAML, and that an operation without an override does not emit anupstream.api/...andinternal/...suites pass, including the HTTPRoute compile tests (this change is purely additive and does not alter existing routing logic).Note on merge order
This PR depends on the gateway-controller understanding
operations[].upstream.ref, which lands in PR #2012. It should therefore be merged after #2012, and rebased onto amainthat includes it, so the end-to-end path works at runtime.