Skip to content

Commit

Permalink
S-108712 Review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
d-venkat committed May 16, 2024
1 parent 7bfd3f9 commit b24f747
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 28 deletions.
54 changes: 49 additions & 5 deletions templates/_resources.tpl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{/* vim: set filetype=mustache: */}}

{{/*
Return a resource request/limit object based on a given preset.
Return deploy master and worker resource request/limit object based on a given preset.
These presets are for basic testing and not meant to be used in production
{{ include "deploy.resources.preset" (dict "type" "nano") -}}
*/}}
Expand Down Expand Up @@ -29,12 +29,56 @@ These presets are for basic testing and not meant to be used in production
"limits" (dict "cpu" "24.0" "memory" "48Gi")
)
"xlarge" (dict
"requests" (dict "cpu" "32" "memory" "64Gi")
"limits" (dict "cpu" "64" "memory" "96Gi")
"requests" (dict "cpu" "32.0" "memory" "64Gi")
"limits" (dict "cpu" "64.0" "memory" "96Gi")
)
"2xlarge" (dict
"requests" (dict "cpu" "64" "memory" "128Gi")
"limits" (dict "cpu" "128" "memory" "256Gi")
"requests" (dict "cpu" "64.0" "memory" "128Gi")
"limits" (dict "cpu" "128.0" "memory" "256Gi")
)
}}
{{- 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 -}}

{{/*
Return deploy central configuration resource request/limit object based on a given preset.
These presets are for basic testing and not meant to be used in production
{{ include "centralConfiguration.resources.preset" (dict "type" "nano") -}}
*/}}
{{- define "centralConfiguration.resources.preset" -}}
{{/* The limits are the requests increased by 50%*/}}
{{- $presets := dict
"nano" (dict
"requests" (dict "cpu" "100m" "memory" "128Mi")
"limits" (dict "cpu" "150m" "memory" "192Mi")
)
"micro" (dict
"requests" (dict "cpu" "250m" "memory" "256Mi")
"limits" (dict "cpu" "375m" "memory" "384Mi")
)
"small" (dict
"requests" (dict "cpu" "500m" "memory" "512Mi")
"limits" (dict "cpu" "750m" "memory" "768Mi")
)
"medium" (dict
"requests" (dict "cpu" "500m" "memory" "1024Mi")
"limits" (dict "cpu" "750m" "memory" "1536Mi")
)
"large" (dict
"requests" (dict "cpu" "1.0" "memory" "2048Mi")
"limits" (dict "cpu" "1.5" "memory" "3072Mi")
)
"xlarge" (dict
"requests" (dict "cpu" "1.5" "memory" "4096Mi")
"limits" (dict "cpu" "3.0" "memory" "6144Mi")
)
"2xlarge" (dict
"requests" (dict "cpu" "1.5" "memory" "4096Mi")
"limits" (dict "cpu" "6.0" "memory" "12288Mi")
)
}}
{{- if hasKey $presets .type -}}
Expand Down
2 changes: 1 addition & 1 deletion templates/deploy-centralconfiguration-statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ spec:
{{- if .Values.centralConfiguration.resources }}
resources: {{- toYaml .Values.centralConfiguration.resources | nindent 12 }}
{{- else if ne .Values.centralConfiguration.resourcesPreset "none" }}
resources: {{- include "deploy.resources.preset" (dict "type" .Values.centralConfiguration.resourcesPreset) | nindent 12 }}
resources: {{- include "centralConfiguration.resources.preset" (dict "type" .Values.centralConfiguration.resourcesPreset) | nindent 12 }}
{{- end }}
volumeMounts:
{{- range $k, $v := .Values.centralConfiguration.configuration }}
Expand Down
7 changes: 5 additions & 2 deletions templates/deploy-master-statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ spec:
{{- else }}
value: {{ .Values.centralConfiguration.service.ports.ccHttp | quote }}
{{- end }}
resources: {{- include "common.resources.preset" (dict "type" "nano") | nindent 12 }}
{{- if and (not .Values.external.db.enabled) .Values.postgresql.install }}
- name: wait-for-postgresql
image: {{ include "deploy.busyBox.image" . }}
Expand All @@ -135,6 +136,7 @@ spec:
value: {{ include "postgresql.subchart" . }}
- name: POSTGRESQL_PORT
value: {{ (include "deploy.postgresql.service.port" .) | quote }}
resources: {{- include "common.resources.preset" (dict "type" "nano") | nindent 12 }}
{{- end }}
{{- if and (not .Values.external.mq.enabled) .Values.rabbitmq.install }}
- name: wait-for-rabbitmq
Expand All @@ -153,6 +155,7 @@ spec:
value: {{ include "rabbitmq.subchart" . }}
- name: RABBITMQ_PORT
value: {{ .Values.rabbitmq.service.ports.amqp | quote }}
resources: {{- include "common.resources.preset" (dict "type" "nano") | nindent 12 }}
{{- end }}
{{- end }}
{{- if and .Values.master.volumePermissions.enabled .Values.master.persistence.enabled }}
Expand All @@ -168,8 +171,8 @@ spec:
securityContext: {{- .Values.master.volumePermissions.containerSecurityContext | toYaml | nindent 12 }}
{{- if .Values.master.volumePermissions.resources }}
resources: {{- toYaml .Values.master.volumePermissions.resources | nindent 12 }}
{{- else if ne .Values.master.volumePermissions.resourcesPreset "none" }}
resources: {{- include "deploy.resources.preset" (dict "type" .Values.master.volumePermissions.resourcesPreset) | nindent 12 }}
{{- else }}
resources: {{- include "common.resources.preset" (dict "type" "nano") | nindent 12 }}
{{- end }}
volumeMounts:
{{- range $path := .Values.master.persistence.paths }}
Expand Down
8 changes: 6 additions & 2 deletions templates/deploy-worker-statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ spec:
{{- else }}
value: {{ .Values.centralConfiguration.service.ports.ccHttp | quote }}
{{- end }}
resources: {{- include "common.resources.preset" (dict "type" "nano") | nindent 12 }}
{{- if and (not .Values.external.db.enabled) .Values.postgresql.install }}
- name: wait-for-postgresql
image: {{ include "deploy.busyBox.image" . }}
Expand All @@ -139,6 +140,7 @@ spec:
value: {{ include "postgresql.subchart" . }}
- name: POSTGRESQL_PORT
value: {{ (include "deploy.postgresql.service.port" .) | quote }}
resources: {{- include "common.resources.preset" (dict "type" "nano") | nindent 12 }}
{{- end }}
{{- if and (not .Values.external.mq.enabled) .Values.rabbitmq.install }}
- name: wait-for-rabbitmq
Expand All @@ -157,6 +159,7 @@ spec:
value: {{ include "rabbitmq.subchart" . }}
- name: RABBITMQ_PORT
value: {{ .Values.rabbitmq.service.ports.amqp | quote }}
resources: {{- include "common.resources.preset" (dict "type" "nano") | nindent 12 }}
{{- end }}
- name: wait-for-master
image: {{ include "deploy.busyBox.image" . }}
Expand All @@ -178,6 +181,7 @@ spec:
{{- else }}
value: {{ .Values.master.services.lb.ports.deployHttp | quote }}
{{- end }}
resources: {{- include "common.resources.preset" (dict "type" "nano") | nindent 12 }}
{{- end }}
{{- if and .Values.worker.volumePermissions.enabled .Values.worker.persistence.enabled }}
- name: volume-permissions
Expand All @@ -192,8 +196,8 @@ spec:
securityContext: {{- .Values.worker.volumePermissions.containerSecurityContext | toYaml | nindent 12 }}
{{- if .Values.worker.volumePermissions.resources }}
resources: {{- toYaml .Values.worker.volumePermissions.resources | nindent 12 }}
{{- else if ne .Values.worker.volumePermissions.resourcesPreset "none" }}
resources: {{- include "deploy.resources.preset" (dict "type" .Values.worker.volumePermissions.resourcesPreset) | nindent 12 }}
{{- else }}
resources: {{- include "common.resources.preset" (dict "type" "nano") | nindent 12 }}
{{- end }}
volumeMounts:
{{- range $path := .Values.worker.persistence.paths }}
Expand Down
18 changes: 0 additions & 18 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1264,15 +1264,6 @@ master:
find "${path}" -mindepth 1 -maxdepth 1 -not -name ".snapshot" -not -name "lost+found" | \
xargs -r chown -R "{{ .Values.master.containerSecurityContext.runAsUser }}:{{ .Values.master.podSecurityContext.fsGroup }}"
done
## Init Container resource requests and limits
## ref: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/
## 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 master.volumePermissions.resourcesPreset Set container resources according to one common preset (allowed values: none, nano, micro, small, medium, large, xlarge, 2xlarge). This is ignored if volumePermissions.resources is set (volumePermissions.resources is recommended for production).
##
resourcesPreset: "nano"
## @param master.volumePermissions.resources Set container requests and limits for different resources like CPU or memory (essential for production workloads)
## @param master.volumePermissions.resources.limits Init container volume-permissions resource limits
## @param master.volumePermissions.resources.requests Init container volume-permissions resource requests
Expand Down Expand Up @@ -2073,15 +2064,6 @@ worker:
find "${path}" -mindepth 1 -maxdepth 1 -not -name ".snapshot" -not -name "lost+found" | \
xargs -r chown -R "{{ .Values.worker.containerSecurityContext.runAsUser }}:{{ .Values.worker.podSecurityContext.fsGroup }}"
done
## Init Container resource requests and limits
## ref: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/
## 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 worker.volumePermissions.resourcesPreset Set container resources according to one common preset (allowed values: none, nano, micro, small, medium, large, xlarge, 2xlarge). This is ignored if volumePermissions.resources is set (volumePermissions.resources is recommended for production).
##
resourcesPreset: "nano"
## @param volumePermissions.resources Set container requests and limits for different resources like CPU or memory (essential for production workloads)
## @param worker.volumePermissions.resources.limits Init container volume-permissions resource limits
## @param worker.volumePermissions.resources.requests Init container volume-permissions resource requests
Expand Down

0 comments on commit b24f747

Please sign in to comment.