diff --git a/logstash/templates/statefulset.yaml b/logstash/templates/statefulset.yaml index 239fac33f..28c07b081 100644 --- a/logstash/templates/statefulset.yaml +++ b/logstash/templates/statefulset.yaml @@ -25,6 +25,16 @@ spec: volumeClaimTemplates: - metadata: name: {{ template "logstash.fullname" . }} + {{- if .Values.persistence.labels.enabled }} + labels: + app: "{{ template "logstash.fullname" . }}" + chart: "{{ .Chart.Name }}" + heritage: {{ .Release.Service | quote }} + release: {{ .Release.Name | quote }} + {{- range $key, $value := .Values.labels }} + {{ $key }}: {{ $value | quote }} + {{- end }} + {{- end }} {{- with .Values.persistence.annotations }} annotations: {{ toYaml . | indent 8 }} diff --git a/logstash/tests/logstash_test.py b/logstash/tests/logstash_test.py index 112f2ab6c..0160d3c36 100644 --- a/logstash/tests/logstash_test.py +++ b/logstash/tests/logstash_test.py @@ -301,6 +301,19 @@ def test_adding_persistence(): assert v["spec"]["resources"]["requests"]["storage"] == "1Gi" +def test_adding_persistence_label_in_volumeclaimtemplate(): + config = """ +persistence: + enabled: true + labels: + enabled: true +""" + r = helm_template(config) + v = r["statefulset"][name]["spec"]["volumeClaimTemplates"][0]["metadata"]["labels"] + sts = r["statefulset"][name]["metadata"]["labels"] + assert v == sts + + def test_adding_storageclass_annotation_to_volumeclaimtemplate(): config = """ persistence: diff --git a/logstash/values.yaml b/logstash/values.yaml index 7d4dc4168..fc2e26a33 100644 --- a/logstash/values.yaml +++ b/logstash/values.yaml @@ -126,6 +126,9 @@ podSecurityPolicy: persistence: enabled: false + # Add default labels for the volumeClaimTemplate fo the StatefulSet + labels: + enabled: false annotations: {} extraVolumes: