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

S-108712 [24.1] Introduced custom resourcesPresets for release #301

Open
wants to merge 3 commits into
base: 24.1.x-maintenance
Choose a base branch
from
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
45 changes: 45 additions & 0 deletions templates/_resources.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{{/* vim: set filetype=mustache: */}}

{{/*
Return a resource request/limit object based on a given preset.
These presets are for basic testing and not meant to be used in production
{{ include "release.resources.preset" (dict "type" "nano") -}}
*/}}
{{- define "release.resources.preset" -}}
{{/* The limits are as per the documentation. The requests are limits reduced by approximately 150% and rounded.*/}}
{{- $presets := dict
"nano" (dict
"requests" (dict "cpu" "500m" "memory" "1Gi")
"limits" (dict "cpu" "1.0" "memory" "2Gi")
)
"micro" (dict
"requests" (dict "cpu" "1.0" "memory" "2Gi")
"limits" (dict "cpu" "2.0" "memory" "4Gi")
)
"small" (dict
"requests" (dict "cpu" "2.0" "memory" "5Gi")
"limits" (dict "cpu" "4.0" "memory" "8Gi")
)
"medium" (dict
"requests" (dict "cpu" "5.0" "memory" "10Gi")
"limits" (dict "cpu" "8.0" "memory" "16Gi")
)
"large" (dict
"requests" (dict "cpu" "10.0" "memory" "21Gi")
"limits" (dict "cpu" "16.0" "memory" "32Gi")
)
"xlarge" (dict
"requests" (dict "cpu" "21.0" "memory" "42Gi")
"limits" (dict "cpu" "32.0" "memory" "64Gi")
)
"2xlarge" (dict
"requests" (dict "cpu" "42.0" "memory" "85Gi")
"limits" (dict "cpu" "64.0" "memory" "128Gi")
)
}}
{{- if hasKey $presets .type -}}
{{- index $presets .type | toYaml -}}
{{- else -}}
{{- printf "ERROR: Preset key '%s' invalid. Allowed values are %s" .type (join "," (keys $presets)) | fail -}}
{{- end -}}
{{- end -}}
8 changes: 8 additions & 0 deletions templates/release-statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ spec:
value: {{ include "postgresql.subchart" . }}
- name: POSTGRESQL_PORT
value: {{ (include "release.postgresql.service.port" .) | quote }}
{{- if .Values.defaultInitContainers.resources }}
resources: {{- toYaml .Values.defaultInitContainers.resources | nindent 12 }}
{{- end }}
{{- end }}
{{- if and (not .Values.external.mq.enabled) .Values.rabbitmq.install }}
- name: wait-for-rabbitmq
Expand All @@ -120,6 +123,9 @@ spec:
value: {{ include "rabbitmq.subchart" . }}
- name: RABBITMQ_PORT
value: {{ .Values.rabbitmq.service.ports.amqp | quote }}
{{- if .Values.defaultInitContainers.resources }}
resources: {{- toYaml .Values.defaultInitContainers.resources | nindent 12 }}
{{- end }}
{{- end }}
{{- end }}
{{- if and .Values.volumePermissions.enabled .Values.persistence.enabled }}
Expand Down Expand Up @@ -364,6 +370,8 @@ spec:
{{- end }}
{{- if .Values.resources }}
resources: {{- toYaml .Values.resources | nindent 12 }}
{{- else if ne .Values.resourcesPreset "none" }}
resources: {{- include "release.resources.preset" (dict "type" .Values.resourcesPreset) | nindent 12 }}
{{- end }}
volumeMounts:
{{- range $k, $v := .Values.configuration }}
Expand Down
66 changes: 34 additions & 32 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1273,27 +1273,27 @@ containerSecurityContext:
runAsNonRoot: true

## Release containers' resource requests and limits
## ref: https://kubernetes.io/docs/user-guide/compute-resources/
## ref: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
## We usually recommend not to specify default resources and to leave this as a conscious
## choice for the user. This also increases chances charts run on environments with little
## resources, such as Minikube. If you do want to specify resources, uncomment the following
## lines, adjust them as necessary, and remove the curly braces after 'resources:'.
## @param resourcesPreset Set container resources according to one common preset (allowed values: none, nano, micro, small, medium, large, xlarge, 2xlarge). This is ignored if resources is set (resources is recommended for production).
##
resourcesPreset: "micro"
## @param resources Set container requests and limits for different resources like CPU or memory (essential for production workloads)
## @param resources.limits The resources limits for Release containers
## @param resources.requests The requested resources for Release containers
## Example:
## resources:
## limits:
## cpu: 1000m
## memory: 2Gi
## requests:
## cpu: 1000m
## memory: 2Gi
##
resources:
## Example:
## limits:
## cpu: 1000m
## memory: 2Gi
##
limits: {}
## Examples:
## requests:
## cpu: 1000m
## memory: 2Gi
##
requests: {}
resources: {}

## Configure containers' extra options for liveness and readiness probe
## ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/#configure-probes
Expand All @@ -1310,6 +1310,17 @@ health:
probesLivenessTimeout: 60
probesReadinessTimeout: 60

## @param defaultInitContainers Default init containers for the Release pod
defaultInitContainers:
## @param defaultInitContainers.resources Set default init container requests and limits for different resources like CPU or memory (essential for production workloads)
##
resources:
limits:
cpu: "150m"
memory: "192Mi"
requests:
cpu: "100m"
memory: "128Mi"
## @param initContainers Add init containers to the Release pod
## Example:
## initContainers:
Expand All @@ -1319,6 +1330,7 @@ health:
## ports:
## - name: portname
## containerPort: 1234
## resources: {}
##
initContainers: []
## @param sidecars Add sidecar containers to the Release pod
Expand All @@ -1330,6 +1342,7 @@ initContainers: []
## ports:
## - name: portname
## containerPort: 1234
## resources: {}
##
sidecars: []

Expand Down Expand Up @@ -1376,28 +1389,17 @@ volumePermissions:
find "${path}" -mindepth 1 -maxdepth 1 -not -name ".snapshot" -not -name "lost+found" | \
xargs -r chown -R "{{ .Values.containerSecurityContext.runAsUser }}:{{ .Values.podSecurityContext.fsGroup }}"
done
## Init Container resource requests and limits
## ref: https://kubernetes.io/docs/user-guide/compute-resources/
## We usually recommend not to specify default resources and to leave this as a conscious
## choice for the user. This also increases chances charts run on environments with little
## resources, such as Minikube. If you do want to specify resources, uncomment the following
## lines, adjust them as necessary, and remove the curly braces after 'resources:'.
## @param volumePermissions.resources Set container requests and limits for different resources like CPU or memory (essential for production workloads)
## @param volumePermissions.resources.limits Init container volume-permissions resource limits
## @param volumePermissions.resources.requests Init container volume-permissions resource requests
##
resources:
## Example:
## limits:
## cpu: 100m
## memory: 128Mi
##
limits: {}
## Examples:
## requests:
## cpu: 100m
## memory: 128Mi
##
requests: {}
limits:
cpu: "150m"
memory: "192Mi"
requests:
cpu: "100m"
memory: "128Mi"
## Init container' Security Context
## Note: the chown of the data folder is done to containerSecurityContext.runAsUser
## and not the below volumePermissions.containerSecurityContext.runAsUser
Expand Down