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

[Issue #267] Support fullnameOverride in kibana, filebeat, metricbeat… #330

Merged
merged 2 commits into from
Nov 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions filebeat/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ helm install --name filebeat elastic/filebeat --set imageTag=7.4.1
| `affinity` | Configurable [affinity](https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity) | `{}` |
| `priorityClassName` | The [name of the PriorityClass](https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/#priorityclass). No default is supplied as the PriorityClass must be created first. | `""` |
| `updateStrategy` | The [updateStrategy](https://kubernetes.io/docs/tasks/manage-daemon/update-daemon-set/#daemonset-update-strategy) for the `DaemonSet`. By default Kubernetes will kill and recreate pods on updates. Setting this to `OnDelete` will require that pods be deleted manually. | `RollingUpdate` |
| `fullnameOverride` | Overrides the full name of the resources. If not set the name will default to "`.Release.Name`-`.Values.nameOverride or .Chart.Name`" | `""` |

## Examples

Expand Down
4 changes: 4 additions & 0 deletions filebeat/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 "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 -}}

{{/*
Use the fullname if the serviceAccount value is not set
Expand Down
21 changes: 20 additions & 1 deletion filebeat/tests/filebeat_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def test_defaults():
assert {
'name': 'data',
'hostPath': {
'path': '/var/lib/release-name-filebeat-default-data',
'path': '/var/lib/' + name + '-default-data',
'type': 'DirectoryOrCreate'
}
} in volumes
Expand Down Expand Up @@ -231,3 +231,22 @@ def test_priority_class_name():
r = helm_template(config)
priority_class_name = r['daemonset'][name]['spec']['template']['spec']['priorityClassName']
assert priority_class_name == "highest"

def test_setting_fullnameOverride():
config = '''
fullnameOverride: 'filebeat-custom'
'''
r = helm_template(config)

custom_name = 'filebeat-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
1 change: 1 addition & 0 deletions kibana/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ helm install --name kibana elastic/kibana --set imageTag=7.4.1
| `service` | Configurable [service](https://kubernetes.io/docs/concepts/services-networking/service/) to expose the Kibana service. See [`values.yaml`](./values.yaml) for an example | `type: ClusterIP`<br>`port: 5601`<br>`nodePort:`<br>`annotations: {}` |
| `labels` | Configurable [label](https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/) applied to all Kibana pods | `{}` |
| `lifecycle` | Allows you to add lifecycle configuration. See [values.yaml](./values.yaml) for an example of the formatting. | `{}` |
| `fullnameOverride` | Overrides the full name of the resources. If not set the name will default to "`.Release.Name`-`.Values.nameOverride or .Chart.Name`" | `""` |

## Examples

Expand Down
4 changes: 4 additions & 0 deletions kibana/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 "fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Release.Name .Values.nameOverride -}}
{{- printf "%s-%s" $name .Chart.Name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}

{{/*
Return the appropriate apiVersion for ingress.
Expand Down
13 changes: 13 additions & 0 deletions kibana/tests/kibana_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,3 +406,16 @@ def test_adding_lifecycle_events():
d = r['deployment'][name]['spec']['template']['spec']
p = d['containers'][0]['lifecycle']['postStart']
assert p['exec']['command'][0] == '/bin/true'

def test_setting_fullnameOverride():
config = '''
fullnameOverride: 'kibana-custom'
'''
r = helm_template(config)

custom_name = 'kibana-custom'
assert custom_name in r['deployment']
assert custom_name in r['service']

assert r['service'][custom_name]['spec']['ports'][0]['port'] == 5601
assert r['deployment'][custom_name]['spec']['template']['spec']['containers'][0]['name'] == 'kibana'
1 change: 1 addition & 0 deletions metricbeat/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ helm install --name metricbeat elastic/metricbeat --set imageTag=7.4.1
| `affinity` | Configurable [affinity](https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity) | `{}` |
| `updateStrategy` | The [updateStrategy](https://kubernetes.io/docs/tasks/manage-daemon/update-daemon-set/#daemonset-update-strategy) for the `DaemonSet`. By default Kubernetes will kill and recreate pods on updates. Setting this to `OnDelete` will require that pods be deleted manually. | `RollingUpdate` |
| `replicas` | The replica count for the metricbeat deployment talking to kube-state-metrics | `1` |
| `fullnameOverride` | Overrides the full name of the resources. If not set the name will default to "`.Release.Name`-`.Values.nameOverride or .Chart.Name`" | `""` |

## Examples

Expand Down
4 changes: 4 additions & 0 deletions metricbeat/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 "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 -}}

{{/*
Use the fullname if the serviceAccount value is not set
Expand Down
19 changes: 19 additions & 0 deletions metricbeat/tests/metricbeat_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,3 +239,22 @@ def test_adding_pod_labels():
'''
r = helm_template(config)
assert r['daemonset'][name]['metadata']['labels']['app.kubernetes.io/name'] == 'metricbeat'

def test_setting_fullnameOverride():
config = '''
fullnameOverride: 'metricbeat-custom'
'''
r = helm_template(config)

custom_name = 'metricbeat-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