Phase 5: Dynamic Webhook Middleware Kubernetes Controller#4564
Draft
Sanskarzz wants to merge 4 commits intostacklok:mainfrom
Draft
Phase 5: Dynamic Webhook Middleware Kubernetes Controller#4564Sanskarzz wants to merge 4 commits intostacklok:mainfrom
Sanskarzz wants to merge 4 commits intostacklok:mainfrom
Conversation
Signed-off-by: Sanskarzz <sanskar.gur@gmail.com>
Signed-off-by: Sanskarzz <sanskar.gur@gmail.com>
Signed-off-by: Sanskarzz <sanskar.gur@gmail.com>
Signed-off-by: Sanskarzz <sanskar.gur@gmail.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.
[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
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.