From 948fc29eac7e095ce40769577887de1912939203 Mon Sep 17 00:00:00 2001 From: Morgan Christiansson Date: Wed, 22 Jan 2020 12:22:48 +0000 Subject: [PATCH] [logstash] Add fullnameOverride setting Added fullnameOverride to logstash by copy pasting from kibana/filebeat/metricbeat charts --- logstash/README.md | 1 + logstash/templates/_helpers.tpl | 4 ++++ logstash/tests/logstash_test.py | 19 +++++++++++++++++++ 3 files changed, 24 insertions(+) diff --git a/logstash/README.md b/logstash/README.md index 8b6470c5a..ba46512df 100644 --- a/logstash/README.md +++ b/logstash/README.md @@ -101,6 +101,7 @@ helm install --name logstash elastic/logstash --set imageTag=7.5.2 | `updateStrategy` | The [updateStrategy](https://kubernetes.io/docs/tutorials/stateful-application/basic-stateful-set/#updating-statefulsets) for the statefulset. By default Kubernetes will wait for the cluster to be green after upgrading each pod. Setting this to `OnDelete` will allow you to manually delete each pod during upgrades | `RollingUpdate` | | `volumeClaimTemplate` | Configuration for the [volumeClaimTemplate for statefulsets](https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#stable-storage). You will want to adjust the storage (default `30Gi`) and the `storageClassName` if you are using a different storage class | `accessModes: [ "ReadWriteOnce" ]`
`resources.requests.storage: 1Gi` | | `rbac` | Configuration for creating a role, role binding and service account as part of this helm chart with `create: true`. Also can be used to reference an external service account with `serviceAccountName: "externalServiceAccountName"`. | `create: false`
`serviceAccountName: ""` | +| `fullnameOverride` | Overrides the full name of the resources. If not set the name will default to "`.Release.Name`-`.Values.nameOverride or .Chart.Name`" | `""` | ## Try it out diff --git a/logstash/templates/_helpers.tpl b/logstash/templates/_helpers.tpl index 417b56b05..162a3ee08 100755 --- a/logstash/templates/_helpers.tpl +++ b/logstash/templates/_helpers.tpl @@ -11,9 +11,13 @@ Create a default fully qualified app name. We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). */}} {{- define "logstash.fullname" -}} +{{- if .Values.fullnameOverride -}} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} +{{- else -}} {{- $name := default .Chart.Name .Values.nameOverride -}} {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} {{- end -}} +{{- end -}} {{/* Return the appropriate apiVersion for statefulset. diff --git a/logstash/tests/logstash_test.py b/logstash/tests/logstash_test.py index 348fb3419..976aa96e4 100755 --- a/logstash/tests/logstash_test.py +++ b/logstash/tests/logstash_test.py @@ -571,3 +571,22 @@ def test_adding_a_service(): assert len(s['spec']['ports']) == 1 assert s['spec']['ports'][0] == { 'name': 'beats', 'port': 5044, 'protocol': 'TCP', 'targetPort': 5044} + +def test_setting_fullnameOverride(): + config = ''' +fullnameOverride: 'logstash-custom' +''' + r = helm_template(config) + + custom_name = 'logstash-custom' + assert custom_name in r['daemonset'] + assert r['daemonset'][custom_name]['spec']['template']['spec']['containers'][0]['name'] == project + assert r['daemonset'][custom_name]['spec']['template']['spec']['serviceAccountName'] == name + volumes = r['daemonset'][custom_name]['spec']['template']['spec']['volumes'] + assert { + 'name': 'data', + 'hostPath': { + 'path': '/var/lib/' + custom_name + '-default-data', + 'type': 'DirectoryOrCreate' + } + } in volumes