Skip to content
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

Adds min and max to LimitRange #2088

Merged
merged 3 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions chart/templates/limitrange.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,18 @@ spec:
{{- range $key, $val := .Values.policies.limitRange.defaultRequest }}
{{ $key }}: {{ $val | quote }}
{{- end }}
{{- if .Values.policies.limitRange.min }}
min:
{{- range $key, $val := .Values.policies.limitRange.min }}
{{ $key }}: {{ $val | quote }}
{{- end }}
{{- end }}
{{- if .Values.policies.limitRange.max }}
max:
{{- range $key, $val := .Values.policies.limitRange.max }}
{{ $key }}: {{ $val | quote }}
{{- end }}
{{- end }}
type: Container
{{- end }}
{{- end }}
24 changes: 24 additions & 0 deletions chart/tests/limitrange_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,27 @@ tests:
asserts:
- hasDocuments:
count: 0

- it: check disabled both false
release:
name: my-release
namespace: my-namespace
set:
policies:
limitRange:
enabled: true
min:
cpu: 1
max:
memory: 256Mi
asserts:
- hasDocuments:
count: 1
- equal:
path: spec.limits[0].min.cpu
value: "1"
- equal:
path: spec.limits[0].max.memory
value: "256Mi"


8 changes: 8 additions & 0 deletions chart/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1838,6 +1838,14 @@
"type": "object",
"description": "DefaultRequest are the default request options for the limit range"
},
"max": {
"type": "object",
"description": "Max are the max limits for the limit range"
},
"min": {
"type": "object",
"description": "Min are the min limits for the limit range"
},
"annotations": {
"additionalProperties": {
"type": "string"
Expand Down
4 changes: 4 additions & 0 deletions chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,10 @@ policies:
ephemeral-storage: 3Gi
memory: 128Mi
cpu: 100m
# Min are the min limits for the limit range
min: {}
# Max are the max limits for the limit range
max: {}

# NetworkPolicy specifies network policy options.
networkPolicy:
Expand Down
6 changes: 6 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -1542,6 +1542,12 @@ type LimitRange struct {
// DefaultRequest are the default request options for the limit range
DefaultRequest map[string]interface{} `json:"defaultRequest,omitempty"`

// Max are the max limits for the limit range
Max map[string]interface{} `json:"max,omitempty"`

// Min are the min limits for the limit range
Min map[string]interface{} `json:"min,omitempty"`

LabelsAndAnnotations `json:",inline"`
}

Expand Down
2 changes: 2 additions & 0 deletions config/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,8 @@ policies:
ephemeral-storage: 3Gi
memory: 128Mi
cpu: 100m
min: {}
max: {}

networkPolicy:
enabled: false
Expand Down
Loading