Phase 5: Dynamic Webhook Middleware Kubernetes Controller#4564
Phase 5: Dynamic Webhook Middleware Kubernetes Controller#4564Sanskarzz wants to merge 1 commit intostacklok:mainfrom
Conversation
Signed-off-by: Sanskarzz <sanskar.gur@gmail.com>
37488cf to
b10c8ae
Compare
There was a problem hiding this comment.
Large PR Detected
This PR exceeds 1000 lines of changes and requires justification before it can be reviewed.
How to unblock this PR:
Add a section to your PR description with the following format:
## Large PR Justification
[Explain why this PR must be large, such as:]
- Generated code that cannot be split
- Large refactoring that must be atomic
- Multiple related changes that would break if separated
- Migration or data transformationAlternative:
Consider splitting this PR into smaller, focused changes (< 1000 lines each) for easier review and reduced risk.
See our Contributing Guidelines for more details.
This review will be automatically dismissed once you add the justification section.
|
✅ Large PR justification has been provided. The size review has been dismissed and this PR can now proceed with normal review. |
Large PR justification has been provided. Thank you!
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #4564 +/- ##
==========================================
- Coverage 69.00% 68.91% -0.10%
==========================================
Files 518 521 +3
Lines 54744 55011 +267
==========================================
+ Hits 37777 37910 +133
- Misses 14071 14189 +118
- Partials 2896 2912 +16 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
[WIP] Depends on the merge of Phase 3 PR and 4 PR
Summary
This PR implements the fifth phase of the dynamic webhook middleware configuration system (RFC THV-0017), introducing Kubernetes custom resource definitions (CRDs), their respective controller reconciling mechanisms, and integration into the core
MCPServerlifecycle.Fixes #3401
Large PR Justification
This is a new feature package with a large test suite, and it needs to land as one coherent phase.
Key Changes
MCPWebhookConfigCRD CreationMCPWebhookConfigCRD inapi/v1alpha1matching the specifications described in RFC THV-0017.ValidatingandMutatingwebhooks.HMACSecretReffor signing request payloads.TLSConfig(CA, Client Cert, and Key secrets) for rigorous mTLS connections.fail/ignoreforFailurePolicyto align with the runner's runtime validation requirements.Controller Logic and Finalizers
MCPWebhookConfigReconcilerincmd/thv-operator/controllers/..Status.ConfigHashcalculating changes to the configuration.MCPServersvia.Status.ReferencingServers.MCPWebhookConfigwhile actively referenced by anMCPServer.MCPServer Controller Integration
WebhookConfigRefnatively intoMCPServerSpec.MCPServerStatusto explicitly trace configuration hashes linked via annotation hooks.deploymentNeedsUpdate) to trace webhook Secret updates.createRunConfigFromMCPServerto evaluate and translate webhook settings locally using newly extracted utility functions inpkg/controllerutil/webhook.go.FailurePolicyinbuildWebhookConfigto ensure compatibility with thethv-proxyrunner, regardless of the case used in the CRD.Testing and Verification
mcpwebhookconfig_types_test.go, the controller logic (mcpwebhookconfig_controller_test.go), and utilities (webhook_test.go).chainsawtests ensuring valid configurations proceed through creation securely, rejecting any malformed specs early on with CEL validation endpoints.Type of change
Test plan
task test)task test-e2e)task lint-fix)Manual Verification
Manual testing was performed using a local Kind cluster and the
fetchMCPServer.task operator-deploy-local.kubectl apply -f manual-testing-phase5/echo-server.yaml.MCPWebhookConfigpointing to the echo server withinsecureSkipVerify: true.fetchMCPServerreferencing the config.MCPWebhookConfigand generated aconfigHash.fetchserver picked up the configuration and started thethv-proxyrunner.fetchpod logs and confirmed that the mutating webhook middleware was active and correctly invoking the echo server (resulting in "denied request" logs as expected since the echo server doesn't return a validallowed: trueresponse).MCPWebhookConfig(e.g., changed the failure policy or URL).fetchpod automatically to load the new settings.