Skip to content
Open
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
7 changes: 5 additions & 2 deletions charts/curator/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,16 @@ storageClassName: {{ $storageClass | quote }}
{{- end -}}

{{/*
Create the resource blocks based on environment sizing or allow for overrides
Create the resource blocks based on environment sizing or allow for overrides.
The environment values compared here must stay in sync with the `environment`
enum in values.schema.json (dev, qa, prod) -- a comparison against a value the
schema rejects makes the branch unreachable.
*/}}
{{- define "curator.resources" -}}
{{- if .Values.resources -}}
{{- toYaml .Values.resources -}}
{{- else -}}
{{- if eq .Values.environment "production" -}}
{{- if eq .Values.environment "prod" -}}
requests:
cpu: 1
memory: 1Gi
Expand Down
59 changes: 59 additions & 0 deletions charts/curator/tests/deployment_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,62 @@ tests:
asserts:
- notExists:
path: spec.replicas

# The sizing branches key off `environment`, whose allowed values come from
# values.schema.json (dev, qa, prod). These pin that agreement: a branch
# comparing against a value the schema rejects is unreachable and silently
# falls through to the small block.
- it: uses the production sizing when environment is prod and resources is unset
set:
image.tag: latest
environment: prod
asserts:
- equal:
path: spec.template.spec.containers[0].resources.requests.cpu
value: 1
- equal:
path: spec.template.spec.containers[0].resources.requests.memory
value: 1Gi
- equal:
path: spec.template.spec.containers[0].resources.limits.cpu
value: 1500m
- equal:
path: spec.template.spec.containers[0].resources.limits.memory
value: 2Gi

- it: uses the small sizing for non-prod environments
set:
image.tag: latest
environment: dev
asserts:
- equal:
path: spec.template.spec.containers[0].resources.requests.cpu
value: 500m
- equal:
path: spec.template.spec.containers[0].resources.requests.memory
value: 512Mi
- equal:
path: spec.template.spec.containers[0].resources.limits.cpu
value: 500m
- equal:
path: spec.template.spec.containers[0].resources.limits.memory
value: 512Mi

- it: prefers an explicit resources override over the environment sizing
set:
image.tag: latest
environment: prod
resources:
requests:
cpu: 250m
memory: 256Mi
limits:
cpu: 3.5
memory: 1Gi
asserts:
- equal:
path: spec.template.spec.containers[0].resources.requests.cpu
value: 250m
- equal:
path: spec.template.spec.containers[0].resources.limits.cpu
value: 3.5