Commit 2820b32
committed
Add default resource limits and separate proxy runner resource configuration
Implements default resource limits for MCP server and VirtualMCP server containers
to prevent resource monopolization, with intelligent merging of user-provided values
and separate resource configuration for proxy runner containers.
Per issue #2873, vmcp and MCP server containers lacked default resource limits,
creating security and operational risks where misbehaving containers could
exhaust node resources and affect other workloads.
Additionally, MCPServer deployments have two containers (MCP server + proxy runner)
but only had one resource field (`spec.resources`), creating ambiguity about which
container the resources applied to.
- MCP server container: 500m/100m CPU, 512Mi/128Mi memory
- Proxy runner container: 200m/50m CPU, 256Mi/64Mi memory (lighter weight)
- VirtualMCP server container: 500m/100m CPU, 512Mi/128Mi memory
- Defaults are intelligently merged with user-provided values
- Add `spec.proxyRunnerResources` field for proxy runner container configuration
- Existing `spec.resources` applies to MCP server container
- Clear separation eliminates ambiguity between the two containers
MCP server resources are composed from three sources:
- Defaults → `spec.resources` → `spec.podTemplateSpec` (highest precedence)
Proxy runner resources are composed from:
- Defaults → `spec.proxyRunnerResources`
- Add `resourceRequirementsForMCPServer()`: Merges defaults with spec.resources
- Add `resourceRequirementsForProxyRunner()`: Merges defaults with spec.proxyRunnerResources
- Update `deploymentNeedsUpdate()`: Checks both MCP and proxy resources separately
- Add `PodTemplateSpecBuilder.WithResources()`: Merges resources intelligently
- Add shared utility functions in `pkg/controllerutil/resources.go`
- Add regression tests for `deploymentNeedsUpdate()` resource changes (4 tests)
- Add tests for resource merging in PodTemplateSpecBuilder (2 tests)
- Add tests for default resources and merging (3 tests)
- Add VirtualMCPServer deployment tests (10 tests)
- Total: 19 new tests ensuring no reconciliation loops
- Add `proxyRunnerResources` field to MCPServer CRD
- Regenerate deepcopy methods and CRD manifests
- Bump Helm chart version: 0.0.75 → 0.0.76
- Update example YAML with clear comments
- Document default values and composition precedence
**MCPServer (2 containers):**
- `spec.resources` → MCP server container (via pod template patch)
- `spec.proxyRunnerResources` → Proxy runner container (in deployment)
**VirtualMCPServer (1 container):**
- `spec.resources` → VirtualMCP server container
- Prevents resource exhaustion by providing sensible defaults
- Clear separation: separate fields for separate containers in MCPServer
- User can customize each container independently
- Intelligent merging allows partial overrides
- Prevents reconciliation loops through proper update detection
Fixes #2873
Signed-off-by: 4t8dd <wanger.xyz@gmail.com>1 parent 23bf796 commit 2820b32
File tree
16 files changed
+1613
-63
lines changed- cmd/thv-operator
- api/v1alpha1
- controllers
- pkg/controllerutil
- deploy/charts/operator-crds
- files/crds
- examples/operator/mcp-servers
16 files changed
+1613
-63
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
110 | 116 | | |
111 | 117 | | |
112 | 118 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
22 | 21 | | |
23 | 22 | | |
24 | 23 | | |
| |||
928 | 927 | | |
929 | 928 | | |
930 | 929 | | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
931 | 933 | | |
932 | 934 | | |
933 | 935 | | |
| 936 | + | |
934 | 937 | | |
935 | 938 | | |
936 | 939 | | |
| |||
1062 | 1065 | | |
1063 | 1066 | | |
1064 | 1067 | | |
1065 | | - | |
1066 | | - | |
1067 | | - | |
1068 | | - | |
1069 | | - | |
1070 | | - | |
1071 | | - | |
1072 | | - | |
1073 | | - | |
1074 | | - | |
1075 | | - | |
1076 | | - | |
1077 | | - | |
1078 | | - | |
1079 | | - | |
1080 | | - | |
1081 | | - | |
1082 | | - | |
1083 | | - | |
1084 | | - | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
1085 | 1071 | | |
1086 | 1072 | | |
1087 | 1073 | | |
| |||
1528 | 1514 | | |
1529 | 1515 | | |
1530 | 1516 | | |
| 1517 | + | |
| 1518 | + | |
| 1519 | + | |
1531 | 1520 | | |
1532 | 1521 | | |
1533 | 1522 | | |
| 1523 | + | |
1534 | 1524 | | |
1535 | 1525 | | |
1536 | 1526 | | |
| |||
1560 | 1550 | | |
1561 | 1551 | | |
1562 | 1552 | | |
1563 | | - | |
1564 | | - | |
| 1553 | + | |
| 1554 | + | |
1565 | 1555 | | |
1566 | 1556 | | |
1567 | 1557 | | |
| |||
1656 | 1646 | | |
1657 | 1647 | | |
1658 | 1648 | | |
1659 | | - | |
| 1649 | + | |
| 1650 | + | |
1660 | 1651 | | |
1661 | | - | |
1662 | | - | |
1663 | | - | |
1664 | | - | |
1665 | | - | |
1666 | | - | |
1667 | | - | |
1668 | | - | |
1669 | | - | |
1670 | | - | |
1671 | | - | |
1672 | | - | |
1673 | | - | |
1674 | | - | |
1675 | | - | |
1676 | | - | |
1677 | | - | |
1678 | | - | |
1679 | | - | |
1680 | | - | |
| 1652 | + | |
| 1653 | + | |
| 1654 | + | |
| 1655 | + | |
| 1656 | + | |
| 1657 | + | |
| 1658 | + | |
| 1659 | + | |
| 1660 | + | |
| 1661 | + | |
| 1662 | + | |
| 1663 | + | |
| 1664 | + | |
| 1665 | + | |
| 1666 | + | |
| 1667 | + | |
1681 | 1668 | | |
1682 | 1669 | | |
1683 | 1670 | | |
| |||
0 commit comments