-
Notifications
You must be signed in to change notification settings - Fork 196
feat(customquotas): add #1794
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
base: main
Are you sure you want to change the base?
feat(customquotas): add #1794
Conversation
Signed-off-by: CorentinPtrl <pitrel.corentin@gmail.com>
81bc3e6 to
46ddb6d
Compare
Signed-off-by: CorentinPtrl <pitrel.corentin@gmail.com>
46ddb6d to
209af96
Compare
Signed-off-by: CorentinPtrl <pitrel.corentin@gmail.com>
0e5c591 to
9ebd73c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR introduces custom quota enforcement capabilities by adding CustomQuota (namespaced) and ClusterCustomQuota (cluster-scoped) CRDs with their associated controllers and webhooks. These quotas dynamically source usage values from Kubernetes resources using JSONPath expressions and enforce limits based on label selectors.
Key Changes
- Added new CRDs for CustomQuota and ClusterCustomQuota with status subresources to track usage, available, and claims
- Implemented controllers to reconcile quota status based on matching resources in target namespaces
- Implemented validating webhooks to enforce quota limits on resource create, update, and delete operations
Reviewed changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 20 comments.
Show a summary per file
| File | Description |
|---|---|
| api/v1beta2/customquota_types.go | Defines the CustomQuota CRD structure with spec for limit, source, and scope selectors |
| api/v1beta2/customquota_status.go | Defines status fields for tracking used, available quantities and claims list |
| api/v1beta2/clustercustomquota_types.go | Extends CustomQuota spec with namespace selectors for cluster-scoped quotas |
| api/v1beta2/zz_generated.deepcopy.go | Auto-generated deep copy methods for the new types |
| internal/controllers/customquotas/customquota_controller.go | Controller that reconciles CustomQuota status by aggregating resource usage |
| internal/controllers/customquotas/clustercustomquota_controller.go | Controller that reconciles ClusterCustomQuota status across multiple namespaces |
| internal/controllers/customquotas/utils.go | Utility functions for extracting usage from resources and matching namespaces |
| internal/controllers/customquotas/manager.go | Registers both quota controllers with the manager |
| internal/webhook/customquota/validation/customquota.go | Validating webhook handlers that enforce quota limits on resource operations |
| internal/webhook/customquota/validation/utils.go | Helper function to determine quota type from namespace presence |
| internal/webhook/route/customquotas.go | Webhook route registration for custom quotas |
| cmd/main.go | Integrates custom quota controllers and webhooks into the main application |
| charts/capsule/values.yaml | Adds Helm values for configuring the custom quotas webhook |
| charts/capsule/values.schema.json | JSON schema validation for the new webhook configuration |
| charts/capsule/templates/validatingwebhookconfiguration.yaml | Webhook configuration for quota enforcement on all namespaced resources |
| charts/capsule/templates/crd-lifecycle/rbac.yaml | Adds RBAC permissions for custom quota CRDs |
| charts/capsule/crds/capsule.clastix.io_customquotas.yaml | CRD manifest for namespaced CustomQuota |
| charts/capsule/crds/capsule.clastix.io_clustercustomquotas.yaml | CRD manifest for cluster-scoped ClusterCustomQuota |
| charts/capsule/README.md | Documents the new webhook configuration options |
| e2e/customresource_quota_exceeded_test.go | E2E tests verifying CustomQuota enforcement and resize scenarios |
| e2e/clustercustomresource_quota_exceeded_test.go | E2E tests verifying ClusterCustomQuota enforcement across namespaces |
internal/controllers/customquotas/clustercustomquota_controller.go
Outdated
Show resolved
Hide resolved
Signed-off-by: CorentinPtrl <pitrel.corentin@gmail.com>
Signed-off-by: CorentinPtrl <pitrel.corentin@gmail.com>
Signed-off-by: CorentinPtrl <pitrel.corentin@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 21 out of 21 changed files in this pull request and generated 13 comments.
internal/controllers/customquotas/clustercustomquota_controller.go
Outdated
Show resolved
Hide resolved
internal/controllers/customquotas/clustercustomquota_controller.go
Outdated
Show resolved
Hide resolved
Signed-off-by: CorentinPtrl <pitrel.corentin@gmail.com>
Signed-off-by: CorentinPtrl <pitrel.corentin@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 21 out of 21 changed files in this pull request and generated 24 comments.
internal/controllers/customquotas/clustercustomquota_controller.go
Outdated
Show resolved
Hide resolved
Signed-off-by: CorentinPtrl <pitrel.corentin@gmail.com>
Signed-off-by: CorentinPtrl <pitrel.corentin@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 21 out of 21 changed files in this pull request and generated 12 comments.
Signed-off-by: CorentinPtrl <pitrel.corentin@gmail.com>
This PR adds
CustomQuotaandClusterCustomQuotafrom #1745 CRDs with their controllers to enforce quota limits based on values sourced from Kubernetes resources.Quotas can be scoped using label selectors and dynamically resolved from objects like
ConfigMapExamples