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

Commit

Permalink
[kibana] Add subPath support to secretMounts
Browse files Browse the repository at this point in the history
Fixes: #229

This is needed in situation where you need to mount a specific secret as
a file in a directory that contains other files. This was added for the
Elasticsearch chart to make it possible to mount the keystore, the same
option is needed for Kibana too as seen in in #229.
  • Loading branch information
Crazybus committed Jul 23, 2019
1 parent 899c7d2 commit df7118b
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 3 deletions.
3 changes: 3 additions & 0 deletions kibana/templates/deployment.yaml
Expand Up @@ -112,6 +112,9 @@ spec:
{{- range .Values.secretMounts }}
- name: {{ .name }}
mountPath: {{ .path }}
{{- if .subPath }}
subPath: {{ .subPath }}
{{- end }}
{{- end }}
{{- range $path, $config := .Values.kibanaConfig }}
- name: kibanaconfig
Expand Down
30 changes: 30 additions & 0 deletions kibana/tests/kibana_test.py
Expand Up @@ -364,3 +364,33 @@ def test_adding_pod_labels():
'''
r = helm_template(config)
assert r['deployment'][name]['metadata']['labels']['app.kubernetes.io/name'] == 'kibana'

def test_adding_a_secret_mount_with_subpath():
config = '''
secretMounts:
- name: elastic-certificates
secretName: elastic-certs
path: /usr/share/elasticsearch/config/certs
subPath: cert.crt
'''
r = helm_template(config)
d = r['deployment'][name]['spec']['template']['spec']
assert d['containers'][0]['volumeMounts'][-1] == {
'mountPath': '/usr/share/elasticsearch/config/certs',
'subPath': 'cert.crt',
'name': 'elastic-certificates'
}

def test_adding_a_secret_mount_without_subpath():
config = '''
secretMounts:
- name: elastic-certificates
secretName: elastic-certs
path: /usr/share/elasticsearch/config/certs
'''
r = helm_template(config)
d = r['deployment'][name]['spec']['template']['spec']
assert d['containers'][0]['volumeMounts'][-1] == {
'mountPath': '/usr/share/elasticsearch/config/certs',
'name': 'elastic-certificates'
}
7 changes: 4 additions & 3 deletions kibana/values.yaml
Expand Up @@ -16,9 +16,10 @@ extraEnvs: []
# This is useful for mounting certificates for security and for mounting
# the X-Pack license
secretMounts: []
# - name: elastic-certificates
# secretName: elastic-certificates
# path: /usr/share/elasticsearch/config/certs
# - name: kibana-keystore
# secretName: kibana-keystore
# path: /usr/share/kibana/data/kibana.keystore
# subPath: kibana.keystore # optional

image: "docker.elastic.co/kibana/kibana"
imageTag: "7.2.0"
Expand Down

0 comments on commit df7118b

Please sign in to comment.