Skip to content
This repository has been archived by the owner on May 16, 2023. It is now read-only.

Commit

Permalink
add an opt-in parameter to enable volumeClaimTemplate labels.
Browse files Browse the repository at this point in the history
  • Loading branch information
desaintmartin committed Jun 26, 2020
1 parent be3c093 commit 21a7a06
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions elasticsearch/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ spec:
volumeClaimTemplates:
- metadata:
name: {{ template "elasticsearch.uname" . }}
{{- if .Values.persistence.labels.enabled }}
labels:
heritage: {{ .Release.Service | quote }}
release: {{ .Release.Name | quote }}
Expand All @@ -34,6 +35,7 @@ spec:
{{- range $key, $value := .Values.labels }}
{{ $key }}: {{ $value | quote }}
{{- end }}
{{- end }}
{{- with .Values.persistence.annotations }}
annotations:
{{ toYaml . | indent 8 }}
Expand Down
16 changes: 16 additions & 0 deletions elasticsearch/tests/elasticsearch_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,10 @@ def test_defaults():
assert c["volumeMounts"][0]["mountPath"] == "/usr/share/elasticsearch/data"
assert c["volumeMounts"][0]["name"] == uname

# volumeClaimTemplates
v = r["statefulset"][uname]["spec"]["volumeClaimTemplates"][0]
assert v["metadata"]["name"] == uname
assert v["metadata"]["labels"] == {}
assert v["spec"]["accessModes"] == ["ReadWriteOnce"]
assert v["spec"]["resources"]["requests"]["storage"] == "30Gi"

Expand Down Expand Up @@ -479,6 +481,20 @@ def test_adding_multiple_persistence_annotations():
assert annotations["world"] == "hello"


def test_enabling_persistence_label_in_volumeclaimtemplate():
config = """
persistence:
labels:
enabled: true
"""
r = helm_template(config)
volume_claim_template_labels = r["statefulset"][uname]["spec"][
"volumeClaimTemplates"
][0]["metadata"]["labels"]
statefulset_labels = r["statefulset"][uname]["metadata"]["labels"]
assert volume_claim_template_labels == statefulset_labels


def test_adding_a_secret_mount():
config = """
secretMounts:
Expand Down
3 changes: 3 additions & 0 deletions elasticsearch/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ podSecurityPolicy:

persistence:
enabled: true
labels:
# Add default labels for the volumeClaimTemplate fo the StatefulSet
enabled: false
annotations: {}

extraVolumes: []
Expand Down

0 comments on commit 21a7a06

Please sign in to comment.