Skip to content

Commit

Permalink
Merge pull request #292 from joejulian/229-minimum-ram
Browse files Browse the repository at this point in the history
redpanda: allow super small memory settings for development
  • Loading branch information
joejulian authored Jan 31, 2023
2 parents 706c821 + 32e46be commit 4b53835
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 20 deletions.
2 changes: 1 addition & 1 deletion charts/redpanda/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type: application
# The chart version and the app version are not the same and will not track
# together. The chart version is a semver representation of changes to this
# chart.
version: 2.6.3
version: 2.6.4

# The app version is the default version of Redpanda to install.
appVersion: v22.3.10
Expand Down
17 changes: 16 additions & 1 deletion charts/redpanda/templates/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,23 @@ limitations under the License.
*/}}

{{/*
Any rpk command that's given to the user in in this file must be defined in _example-commands.tpl and tested in a test.
Add warnings to the warnings template
*/}}
{{ $warnings := (fromJson (include "warnings" .)).result }}
{{- if $warnings }}
---
{{ range $warning := $warnings }}
{{ $warning }}
{{- end }}

---
{{- end }}

{{-
/*
Any rpk command that's given to the user in in this file must be defined in _example-commands.tpl and tested in a test.
*/
-}}

{{- $anySASL := (include "sasl-enabled" . | fromJson).bool }}
{{- $rpk := deepCopy . }}
Expand Down
62 changes: 44 additions & 18 deletions charts/redpanda/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,8 @@ Generate configuration needed for rpk
{{- if eq $result 0 -}}
{{- "unable to get memory value" | fail -}}
{{- end -}}
{{- if lt $result 2000 -}}
{{- printf "\n%d is below the minimum recommended value for Redpanda" $result | fail -}}
{{- if lt $result 256 -}}
{{- printf "\n%d is below the minimum value for Redpanda" $result | fail -}}
{{- end -}}
{{- if gt (add $result (include "redpanda-reserve-memory" .)) (include "container-memory" . | int64) -}}
{{- printf "\nNot enough container memory for Redpanda memory values\nredpanda: %d, reserve: %d, container: %d" $result (include "redpanda-reserve-memory" . | int64) (include "container-memory" . | int64) | fail -}}
Expand Down Expand Up @@ -366,22 +366,22 @@ Generate configuration needed for rpk
{{- end -}}
{{- define "tunable" -}}
{{- $tunable := dig "tunable" dict .Values.config }}
{{- if (include "redpanda-atleast-22-3-0" . | fromJson).bool }}
{{- toYaml $tunable | nindent 4 }}
{{- else if (include "redpanda-atleast-22-2-0" . | fromJson).bool }}
{{- $tunable = unset $tunable "log_segment_size_min" }}
{{- $tunable = unset $tunable "log_segment_size_max" }}
{{- $tunable = unset $tunable "kafka_batch_max_bytes" }}
{{- toYaml $tunable | nindent 4 }}
{{- else if (include "redpanda-atleast-22-1-1" . | fromJson).bool }}
{{- $tunable = unset $tunable "log_segment_size_min" }}
{{- $tunable = unset $tunable "log_segment_size_max" }}
{{- $tunable = unset $tunable "kafka_batch_max_bytes" }}
{{- $tunable = unset $tunable "topic_partitions_per_shard" }}
{{- toYaml $tunable | nindent 4 }}
{{- end }}
{{- end }}
{{- $tunable := dig "tunable" dict .Values.config -}}
{{- if (include "redpanda-atleast-22-3-0" . | fromJson).bool -}}
{{- toYaml $tunable | nindent 4 -}}
{{- else if (include "redpanda-atleast-22-2-0" . | fromJson).bool -}}
{{- $tunable = unset $tunable "log_segment_size_min" -}}
{{- $tunable = unset $tunable "log_segment_size_max" -}}
{{- $tunable = unset $tunable "kafka_batch_max_bytes" -}}
{{- toYaml $tunable | nindent 4 -}}
{{- else if (include "redpanda-atleast-22-1-1" . | fromJson).bool -}}
{{- $tunable = unset $tunable "log_segment_size_min" -}}
{{- $tunable = unset $tunable "log_segment_size_max" -}}
{{- $tunable = unset $tunable "kafka_batch_max_bytes" -}}
{{- $tunable = unset $tunable "topic_partitions_per_shard" -}}
{{- toYaml $tunable | nindent 4 -}}
{{- end -}}
{{- end -}}
{{- define "redpanda-atleast-22-1-1" -}}
{{- toJson (dict "bool" (or (not (eq .Values.image.repository "vectorized/redpanda")) (include "redpanda.semver" . | semverCompare ">=22.1.1"))) -}}
Expand Down Expand Up @@ -475,3 +475,29 @@ Set default path for tiered storage cache or use one provided
{{- .Values.storage.tieredConfig.cloud_storage_cache_directory }}
{{- end }}
{{- end }}

{{/*
"warnings" is an aggregate that returns a list of warnings to be shown in NOTES.txt
*/}}
{{- define "warnings" -}}
{{- $result := list -}}
{{- $warnings := list "redpanda-memory-warning" -}}
{{- range $t := $warnings -}}
{{- $warning := printf "**Warning**: %s" (include $t $) -}}
{{- if $warning -}}
{{- $result = append $result $warning -}}
{{- end -}}
{{- end -}}
{{/* fromJson cannot decode list */}}
{{- toJson (dict "result" $result) -}}
{{- end -}}

{{/*
return a warning if the chart is configured with insufficient memory
*/}}
{{- define "redpanda-memory-warning" -}}
{{- $result := (include "redpanda-memory" .) | int -}}
{{- if lt $result 2000 -}}
{{- printf "%d is below the minimum recommended value for Redpanda" $result -}}
{{- end -}}
{{- end -}}

0 comments on commit 4b53835

Please sign in to comment.