diff --git a/elasticsearch/README.md b/elasticsearch/README.md index 95efdbaaf..c5b33d095 100644 --- a/elasticsearch/README.md +++ b/elasticsearch/README.md @@ -160,6 +160,7 @@ support multiple versions with minimal changes. | `secretMounts` | Allows you easily mount a secret as a file inside the StatefulSet. Useful for mounting certificates and other secrets. See [values.yaml][] for an example | `[]` | | `securityContext` | Allows you to set the [securityContext][] for the container | see [values.yaml][] | | `service.annotations` | [LoadBalancer annotations][] that Kubernetes will use for the service. This will configure load balancer if `service.type` is `LoadBalancer` | `{}` | +| `service.enabled` | Enable non-headless service | `true` | | `service.externalTrafficPolicy` | Some cloud providers allow you to specify the [LoadBalancer externalTrafficPolicy][]. Kubernetes will use this to preserve the client source IP. This will configure load balancer if `service.type` is `LoadBalancer` | `""` | | `service.httpPortName` | The name of the http port within the service | `http` | | `service.labelsHeadless` | Labels to be added to headless service | `{}` | diff --git a/elasticsearch/templates/service.yaml b/elasticsearch/templates/service.yaml index ee7ba5c9c..1da695185 100644 --- a/elasticsearch/templates/service.yaml +++ b/elasticsearch/templates/service.yaml @@ -1,4 +1,5 @@ --- +{{- if .Values.service.enabled -}} kind: Service apiVersion: v1 metadata: @@ -43,6 +44,7 @@ spec: {{- if .Values.service.externalTrafficPolicy }} externalTrafficPolicy: {{ .Values.service.externalTrafficPolicy }} {{- end }} +{{- end }} --- kind: Service apiVersion: v1 diff --git a/elasticsearch/tests/elasticsearch_test.py b/elasticsearch/tests/elasticsearch_test.py index 32bef1e82..768a2aa33 100755 --- a/elasticsearch/tests/elasticsearch_test.py +++ b/elasticsearch/tests/elasticsearch_test.py @@ -799,6 +799,23 @@ def test_scheduler_name(): ) +def test_disabling_non_headless_service(): + config = "" + + r = helm_template(config) + + assert uname in r["service"] + + config = """ +service: + enabled: false +""" + + r = helm_template(config) + + assert uname not in r["service"] + + def test_adding_a_nodePort(): config = "" diff --git a/elasticsearch/values.yaml b/elasticsearch/values.yaml index 63a2aa60b..d996b42a0 100755 --- a/elasticsearch/values.yaml +++ b/elasticsearch/values.yaml @@ -180,6 +180,7 @@ httpPort: 9200 transportPort: 9300 service: + enabled: true labels: {} labelsHeadless: {} type: ClusterIP