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

Commit

Permalink
Merge pull request #330 from tusciucalecs/issue_267
Browse files Browse the repository at this point in the history
[Issue #267] Support fullnameOverride in kibana, filebeat, metricbeat…
jmlrt authored Nov 18, 2019

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
2 parents 409752b + 43aeac4 commit 0411010
Showing 9 changed files with 67 additions and 1 deletion.
1 change: 1 addition & 0 deletions filebeat/README.md
Original file line number Diff line number Diff line change
@@ -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

4 changes: 4 additions & 0 deletions filebeat/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 "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
21 changes: 20 additions & 1 deletion filebeat/tests/filebeat_test.py
Original file line number Diff line number Diff line change
@@ -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
@@ -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
@@ -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

4 changes: 4 additions & 0 deletions kibana/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 "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.
13 changes: 13 additions & 0 deletions kibana/tests/kibana_test.py
Original file line number Diff line number Diff line change
@@ -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
@@ -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

4 changes: 4 additions & 0 deletions metricbeat/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 "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
19 changes: 19 additions & 0 deletions metricbeat/tests/metricbeat_test.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 0411010

Please sign in to comment.