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

Commit

Permalink
Logstash: Add option to configure PVC labels in StatefulSets
Browse files Browse the repository at this point in the history
Allows adding custom labels to PVCs created by StatefulSets
  • Loading branch information
Martin Lillemets committed May 16, 2022
1 parent 2246439 commit 9f6cbb8
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
10 changes: 10 additions & 0 deletions logstash/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
13 changes: 13 additions & 0 deletions logstash/tests/logstash_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 3 additions & 0 deletions logstash/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ podSecurityPolicy:

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

extraVolumes:
Expand Down

0 comments on commit 9f6cbb8

Please sign in to comment.