From 1eac119672b97691491a4dc1e11030839fdfa227 Mon Sep 17 00:00:00 2001 From: Michael Russell Date: Mon, 17 Jun 2019 19:53:23 +0200 Subject: [PATCH] [kibana] Always set server.host to the docker default Fixes: #156 The Kibana docker image comes with [server.host](https://github.com/elastic/kibana/blob/3a1d4ad0acd986f55b7da532878e842dd62a1237/src/dev/build/tasks/os_packages/docker_generator/templates/kibana_yml.template.js#L30) set in the default `kibana.yml`. This setting is needed to make sure that services and ingress work correctly. If someone overrides the kibana.yml with custom configuration this setting changes back to the kibana default which is `localhost`. This keeps the setting consistent for the default helm install with default values and for anyone customising `kibana.yml` --- kibana/README.md | 1 + kibana/examples/default/test/goss.yaml | 6 ++++++ kibana/examples/security/security.yml | 6 ++++++ kibana/templates/deployment.yaml | 2 ++ kibana/tests/kibana_test.py | 14 ++++++++++++++ kibana/values.yaml | 2 ++ 6 files changed, 31 insertions(+) diff --git a/kibana/README.md b/kibana/README.md index 2d2415922..535dc5c83 100644 --- a/kibana/README.md +++ b/kibana/README.md @@ -50,6 +50,7 @@ helm install --name kibana elastic/kibana --version 7.1.1 --set imageTag=7.1.1 | `imagePullPolicy` | The Kubernetes [imagePullPolicy](https://kubernetes.io/docs/concepts/containers/images/#updating-images) value | `IfNotPresent` | | `resources` | Allows you to set the [resources](https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/) for the statefulset | `requests.cpu: 100m`
`requests.memory: 2Gi`
`limits.cpu: 1000m`
`limits.memory: 2Gi` | | `protocol` | The protocol that will be used for the readinessProbe. Change this to `https` if you have `server.ssl.enabled: true` set | `http` | +| `serverHost` | The [`server.host`](https://www.elastic.co/guide/en/kibana/current/settings.html) Kibana setting. This is set explicitly so that the default always matches what comes with the docker image. | `0.0.0.0` | | `healthCheckPath` | The path used for the readinessProbe to check that Kibana is ready | `/app/kibana` | | `kibanaConfig` | Allows you to add any config files in `/usr/share/kibana/config/` such as `kibana.yml`. See [values.yaml](./values.yaml) for an example of the formatting. | `{}` | | `podSecurityContext` | Allows you to set the [securityContext](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod) for the pod | `{}` | diff --git a/kibana/examples/default/test/goss.yaml b/kibana/examples/default/test/goss.yaml index 5710496ce..9c36edb4d 100644 --- a/kibana/examples/default/test/goss.yaml +++ b/kibana/examples/default/test/goss.yaml @@ -12,3 +12,9 @@ http: http://helm-kibana-default-kibana:5601/app/kibana: status: 200 timeout: 2000 + +port: + tcp:5601: + listening: true + ip: + - '0.0.0.0' diff --git a/kibana/examples/security/security.yml b/kibana/examples/security/security.yml index 3517ed8e3..9ce3bccc5 100644 --- a/kibana/examples/security/security.yml +++ b/kibana/examples/security/security.yml @@ -34,3 +34,9 @@ secretMounts: - name: kibana-certificates secretName: kibana-certificates path: /usr/share/kibana/config/certs/kibana + +port: + tcp:5601: + listening: true + ip: + - '0.0.0.0' diff --git a/kibana/templates/deployment.yaml b/kibana/templates/deployment.yaml index 52a473d67..ce7b01eac 100644 --- a/kibana/templates/deployment.yaml +++ b/kibana/templates/deployment.yaml @@ -72,6 +72,8 @@ spec: - name: ELASTICSEARCH_HOSTS value: "{{ .Values.elasticsearchHosts }}" {{- end }} + - name: SERVER_HOST + value: "{{ .Values.serverHost }}" {{- if .Values.extraEnvs }} {{ toYaml .Values.extraEnvs | indent 10 }} {{- end }} diff --git a/kibana/tests/kibana_test.py b/kibana/tests/kibana_test.py index fd07c3fc6..b802445f7 100644 --- a/kibana/tests/kibana_test.py +++ b/kibana/tests/kibana_test.py @@ -31,6 +31,9 @@ def test_defaults(): assert c['env'][0]['name'] == 'ELASTICSEARCH_HOSTS' assert c['env'][0]['value'] == elasticsearchHosts + assert c['env'][1]['name'] == 'SERVER_HOST' + assert c['env'][1]['value'] == '0.0.0.0' + assert 'http "/app/kibana"' in c['readinessProbe']['exec']['command'][-1] # Empty customizable defaults @@ -291,3 +294,14 @@ def test_adding_a_nodePort(): r = helm_template(config) assert r['service'][name]['spec']['ports'][0]['nodePort'] == 30001 + +def test_override_the_serverHost(): + config = ''' + serverHost: "localhost" + ''' + + r = helm_template(config) + + c = r['deployment'][name]['spec']['template']['spec']['containers'][0] + assert c['env'][1]['name'] == 'SERVER_HOST' + assert c['env'][1]['value'] == 'localhost' diff --git a/kibana/values.yaml b/kibana/values.yaml index 6cf1bb47e..4075f7efd 100755 --- a/kibana/values.yaml +++ b/kibana/values.yaml @@ -34,6 +34,8 @@ resources: protocol: http +serverHost: "0.0.0.0" + healthCheckPath: "/app/kibana" # Allows you to add any config files in /usr/share/kibana/config/