Skip to content

Commit

Permalink
Merge pull request #2088 from emoreth/adds_min_and_max_to_limitrange
Browse files Browse the repository at this point in the history
Adds min and max to LimitRange
  • Loading branch information
FabianKramm authored Oct 7, 2024
2 parents 9d9edf3 + ae28895 commit 869c78f
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 0 deletions.
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 @@ -1950,6 +1950,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 @@ -805,6 +805,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 @@ -1603,6 +1603,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 @@ -478,6 +478,8 @@ policies:
ephemeral-storage: 3Gi
memory: 128Mi
cpu: 100m
min: {}
max: {}

networkPolicy:
enabled: false
Expand Down

0 comments on commit 869c78f

Please sign in to comment.