Skip to content

CLOUDP-121490 | feat: container resources customization #1713

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Jorgagu
Copy link

@Jorgagu Jorgagu commented May 12, 2025

Summary:

This pull request introduces support for specifying custom resource requirements for MongoDB pods, enabling fine-grained control over resource allocation for different containers. The changes include updates to the CRD, API types, and controller logic to incorporate this functionality.

API Enhancements

  • Added a new ResourcesSpec type in api/v1/mongodbcommunity_types.go to define resource requirements for containers (mongod, agent, readinessProbe, and versionUpgradeHook). This type is integrated into the MongoDBCommunitySpec struct. [1] [2]

CRD Updates

  • Updated the CRD in config/crd/bases/mongodbcommunity.mongodb.com_mongodbcommunity.yaml to include the resources field, allowing users to specify resource requirements for individual containers. This includes descriptions and validation rules for limits and requests.

Controller Modifications

  • Updated the BuildMongoDBReplicaSetStatefulSetModificationFunction in controllers/construct/mongodbstatefulset.go to handle the new ResourcesSpec. This includes passing resource specifications to container creation functions for mongod, agent, readinessProbe, and versionUpgradeHook containers. [1] [2] [3]
  • Modified container creation functions (mongodbContainer, mongodbAgentContainer, versionUpgradeHookInit, readinessProbeInit) to accept and apply resource requirements from the ResourcesSpec. [1] [2] [3] [4]

Test Updates

  • Enhanced the TestMongod_Container test in controllers/construct/build_statefulset_test.go to include a MongoDBCommunity instance without custom resources, ensuring compatibility with the new functionality.

These changes collectively enhance the flexibility and configurability of the MongoDB Kubernetes Operator, allowing users to better manage resource allocation for their deployments.

closes #962

All Submissions:

  • Have you opened an Issue before filing this PR?
  • Have you signed our CLA?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?
  • Put closes #XXXX in your comment to auto-close the issue that your PR fixes (if such).

Jorgagu added 2 commits May 12, 2025 13:40
Allow customization of resource requirements (CPU and memory) for all
containers deployed by the MongoDB Kubernetes operator:
- Add ResourcesSpec to MongoDBCommunitySpec
- Implement safe resource retrieval using reflection
- Support customization for mongod, agent, and init containers
- Fall back to default values when not specified

This enhancement gives users more control over the resource allocation
for MongoDB deployments, which is particularly useful in production
environments with specific resource constraints.
@Jorgagu Jorgagu changed the title feat: container resources customization CLOUDP-121490 - feat: container resources customization May 12, 2025
@Jorgagu Jorgagu changed the title CLOUDP-121490 - feat: container resources customization CLOUDP-121490 | feat: container resources customization May 12, 2025
@Jorgagu
Copy link
Author

Jorgagu commented May 12, 2025

👋 @dan-mckean, I’ve created this PR to close issue #962. Do you have an estimate of when you (or someone else) might review it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

It is not possible to adjust arbiter's resource limits separately from cluster nodes
1 participant