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

[logstash] Add fullnameOverride setting #457

Merged
merged 2 commits into from
Jan 31, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
[logstash] Add fullnameOverride setting
Added fullnameOverride to logstash by copy pasting from kibana/filebeat/metricbeat charts
  • Loading branch information
morganchristiansson committed Jan 31, 2020
commit f47028c177f947ff2842303bfee23807cb727f55
1 change: 1 addition & 0 deletions logstash/README.md
Original file line number Diff line number Diff line change
@@ -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" ]`<br>`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`<br>`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

4 changes: 4 additions & 0 deletions logstash/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -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.
19 changes: 19 additions & 0 deletions logstash/tests/logstash_test.py
Original file line number Diff line number Diff line change
@@ -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']
morganchristiansson marked this conversation as resolved.
Show resolved Hide resolved
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