feat(controller): create prerequisites from annotation#227
Conversation
✅ Deploy Preview for mcp-lifecycle-operator ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: rdwj 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 |
|
|
|
Welcome @rdwj! |
|
Hi @rdwj. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
When the annotation mcp.x-k8s.io/auto-create-prerequisites is set to "true", the operator creates missing ServiceAccounts and ConfigMaps referenced by the MCPServer CR before validation. Resources are owned by the MCPServer so they are cleaned up on deletion. Related: kubernetes-sigs#226
Controller-runtime's client cache requires list and watch permissions to set up informers. Without them, the ensurePrerequisites function cannot check ServiceAccount existence.
d7cb3fc to
9c3cbfe
Compare
Summary
When the annotation
mcp.x-k8s.io/auto-create-prerequisitesis set to"true"on an MCPServer CR, the operator creates missing ServiceAccounts and ConfigMaps before validation. Resources are owned by the MCPServer and cleaned up on deletion.Motivation
Deploying MCP servers from the RHOAI catalog requires manually creating ServiceAccounts and ConfigMaps per namespace before the MCPServer CR will reconcile. This annotation-gated feature automates that step for catalog-based deployments.
Addresses #226
Changes
internal/controller/mcpserver_controller_prerequisites.go—ensurePrerequisites()functioninternal/controller/mcpserver_controller.go— callensurePrerequisites()before validation, updated RBAC markersconfig/rbac/role.yaml— addedlist,watch, andcreateverbs for serviceaccountsinternal/controller/mcpserver_controller_prerequisites_test.go— 7 test cases covering annotation gating, resource creation, idempotency, and owner referencesTesting
Validated on a live RHOAI 3.4 / OpenShift 4.20 cluster:
make test)make lint)