diff --git a/packages/apps/tenant/README.md b/packages/apps/tenant/README.md index 5cd48995c..5b9c712f5 100644 --- a/packages/apps/tenant/README.md +++ b/packages/apps/tenant/README.md @@ -104,6 +104,7 @@ The `resourceQuotas` parameter allows you to limit resources available to the te - `memory` - Total memory (e.g., `"4Gi"` or `"512Mi"`) - `ephemeral-storage` - Ephemeral storage limit (e.g., `"10Gi"`) - `storage` - Total persistent storage (e.g., `"100Gi"`) +- `hugepages-2Mi`, `hugepages-1Gi` - Total huge pages of that size (e.g., `"4Gi"`), converted to `requests.hugepages-` only, as Kubernetes has no limits quota for huge pages **Object count quotas** (passed as-is): - `pods` - Maximum number of pods diff --git a/packages/library/cozy-lib/templates/_resources.tpl b/packages/library/cozy-lib/templates/_resources.tpl index 17ffac8c0..dfab53399 100644 --- a/packages/library/cozy-lib/templates/_resources.tpl +++ b/packages/library/cozy-lib/templates/_resources.tpl @@ -286,6 +286,12 @@ {{- $out := "" }} {{- if and (eq $section "limits") (eq $type "storage") }} {{- $out = "" }} +{{- /* + A ResourceQuota accepts hugepages only as requests.hugepages-, + limits.hugepages- is rejected and the whole quota with it. +*/}} +{{- else if and (eq $section "limits") (hasPrefix "hugepages-" $type) }} +{{- $out = "" }} {{- else if and (eq $section "limits") (has $type $rawQuotaKeys) }} {{- $out = $type }} {{- else if not (has $type $rawQuotaKeys) }} diff --git a/packages/tests/cozy-lib-tests/tests/quota_test.yaml b/packages/tests/cozy-lib-tests/tests/quota_test.yaml index 0ba2260c4..0604ca5ee 100644 --- a/packages/tests/cozy-lib-tests/tests/quota_test.yaml +++ b/packages/tests/cozy-lib-tests/tests/quota_test.yaml @@ -48,3 +48,32 @@ tests: - notExists: path: spec.hard["requests.services.loadbalancers"] + + - it: renders hugepages only as requests + set: + quota: + hugepages-2Mi: "4Gi" + hugepages-1Gi: "2Gi" + _cluster: {} + _namespace: {} + + release: + name: myrelease + namespace: default + revision: 1 + isUpgrade: false + + asserts: + - equal: + path: spec.hard["requests.hugepages-2Mi"] + value: "4Gi" + + - equal: + path: spec.hard["requests.hugepages-1Gi"] + value: "2Gi" + + - notExists: + path: spec.hard["limits.hugepages-2Mi"] + + - notExists: + path: spec.hard["limits.hugepages-1Gi"]