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

Commit

Permalink
[logstash] Add fullnameOverride setting
Browse files Browse the repository at this point in the history
Added fullnameOverride to logstash by copy pasting from kibana/filebeat/metricbeat charts
  • Loading branch information
morganchristiansson committed Jan 22, 2020
1 parent a6de6af commit 948fc29
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions logstash/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions logstash/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
19 changes: 19 additions & 0 deletions logstash/tests/logstash_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 948fc29

Please sign in to comment.