Skip to content

[bitnami/valkey-cluster] Add support for templating nodes, replicas, resources, and persistent storage values #32520

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

Closed
wants to merge 9 commits into from
8 changes: 6 additions & 2 deletions bitnami/valkey-cluster/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# Changelog

## 2.2.0 (2025-02-21)
## 2.2.1 (2025-03-21)

* [bitnami/valkey-cluster] Set `usePasswordFiles=true` by default ([#32122](https://github.com/bitnami/charts/pull/32122))
* [bitnami/valkey-cluster] Add support for templating nodes, replicas, resources, and persistent storage values ([#32520](https://github.com/bitnami/charts/pull/32520))

## 2.2.0 (2025-02-24)

* [bitnami/valkey-cluster] Set `usePasswordFiles=true` by default (#32122) ([c46b8f0](https://github.com/bitnami/charts/commit/c46b8f0029226245c04a3fed93225e82a9ab3e57)), closes [#32122](https://github.com/bitnami/charts/issues/32122)

## <small>2.1.3 (2025-02-20)</small>

Expand Down
2 changes: 1 addition & 1 deletion bitnami/valkey-cluster/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ name: valkey-cluster
sources:
- https://github.com/bitnami/charts/tree/main/bitnami/valkey-cluster
- https://github.com/bitnami/containers/tree/main/bitnami/vakey-cluster
version: 2.2.0
version: 2.2.1
2 changes: 1 addition & 1 deletion bitnami/valkey-cluster/templates/update-cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ spec:
value: {{ .Values.valkey.containerPorts.valkey | quote }}
{{- end }}
- name: VALKEY_CLUSTER_REPLICAS
value: {{ .Values.cluster.replicas | quote }}
value: {{ if eq (typeOf .Values.cluster.replicas) "float64" -}}{{ .Values.cluster.replicas | quote }}{{- else -}}{{ tpl .Values.cluster.replicas . | quote }}{{- end }}
{{- if .Values.usePassword }}
- name: REDISCLI_AUTH
valueFrom:
Expand Down
12 changes: 6 additions & 6 deletions bitnami/valkey-cluster/templates/valkey-statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ spec:
{{- $podLabels := include "common.tplvalues.merge" ( dict "values" ( list .Values.valkey.podLabels .Values.commonLabels ) "context" . ) }}
selector:
matchLabels: {{- include "common.labels.matchLabels" ( dict "customLabels" $podLabels "context" $ ) | nindent 6 }}
replicas: {{ .Values.cluster.nodes }}
replicas: {{ if eq (typeOf .Values.cluster.nodes) "float64" -}}{{ .Values.cluster.nodes }}{{- else -}}{{ tpl .Values.cluster.nodes . | int }}{{- end }}
Copy link
Member

@migruiz4 migruiz4 Apr 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sorry but I'm not understanding, why the typeOf is required? Can't this be simplified like this?

Suggested change
replicas: {{ if eq (typeOf .Values.cluster.nodes) "float64" -}}{{ .Values.cluster.nodes }}{{- else -}}{{ tpl .Values.cluster.nodes . | int }}{{- end }}
replicas: {{ tpl .Values.cluster.nodes . | int }}

For those values that need to be quoted, like environment variables values: {{ tpl .Values.cluster.nodes $ | int | quote }}

serviceName: {{ include "common.names.fullname" . }}-headless
podManagementPolicy: {{ .Values.valkey.podManagementPolicy }}
template:
Expand Down Expand Up @@ -116,7 +116,7 @@ spec:
{{- if .Values.cluster.init }}
if [[ "$pod_index" == "0" ]]; then
export VALKEY_CLUSTER_CREATOR="yes"
export VALKEY_CLUSTER_REPLICAS="{{ .Values.cluster.replicas }}"
export VALKEY_CLUSTER_REPLICAS="{{ if eq (typeOf .Values.cluster.replicas) "float64" -}}{{ .Values.cluster.replicas | quote }}{{- else -}}{{ tpl .Values.cluster.replicas . | int }}{{- end }}"
fi
{{- end }}
/opt/bitnami/scripts/valkey-cluster/entrypoint.sh /opt/bitnami/scripts/valkey-cluster/run.sh
Expand All @@ -133,7 +133,7 @@ spec:
pod_index="${pod_index[-1]}"
if [[ "$pod_index" == "0" ]]; then
export VALKEY_CLUSTER_CREATOR="yes"
export VALKEY_CLUSTER_REPLICAS="{{ .Values.cluster.replicas }}"
export VALKEY_CLUSTER_REPLICAS="{{ if eq (typeOf .Values.cluster.replicas) "float64" -}}{{ .Values.cluster.replicas | quote }}{{- else -}}{{ tpl .Values.cluster.replicas . | int }}{{- end }}"
fi
{{- end }}
/opt/bitnami/scripts/valkey-cluster/entrypoint.sh /opt/bitnami/scripts/valkey-cluster/run.sh
Expand All @@ -153,7 +153,7 @@ spec:
value: "no"
{{- else }}
- name: VALKEY_NODES
value: "{{ $count := .Values.cluster.nodes | int }}{{ range $i, $v := until $count }}{{ include "common.names.fullname" $ }}-{{ $i }}.{{ template "common.names.fullname" $ }}-headless {{ end }}"
value: '{{- $count := 0 -}}{{ if eq (typeOf .Values.cluster.replicas) "float64" -}}{{ $count = .Values.cluster.nodes | int }}{{- else -}}{{ $count = tpl .Values.cluster.nodes . | int }}{{- end -}}{{ range $i, $v := until $count }}{{ include "common.names.fullname" $ }}-{{ $i }}.{{ template "common.names.fullname" $ }}-headless {{ end }}'
{{- end }}
{{- if .Values.usePassword }}
- name: REDISCLI_AUTH
Expand Down Expand Up @@ -267,7 +267,7 @@ spec:
{{- end }}
{{- end }}
{{- if .Values.valkey.resources }}
resources: {{- toYaml .Values.valkey.resources | nindent 12 }}
resources: {{- include "common.tplvalues.render" (dict "value" .Values.valkey.resources "context" $) | nindent 12 }}
{{- else if ne .Values.valkey.resourcesPreset "none" }}
resources: {{- include "common.resources.preset" (dict "type" .Values.valkey.resourcesPreset) | nindent 12 }}
{{- end }}
Expand Down Expand Up @@ -492,7 +492,7 @@ spec:
{{- end }}
resources:
requests:
storage: {{ .Values.persistence.size | quote }}
storage: {{ tpl .Values.persistence.size . | quote }}
{{- include "common.storage.class" (dict "persistence" .Values.persistence "global" .Values.global) | nindent 8 }}
{{- if or .Values.persistence.matchLabels .Values.persistence.matchExpressions }}
selector:
Expand Down
Loading