From 2c09d54716e7b91ae7559eedd181611094629f77 Mon Sep 17 00:00:00 2001 From: Efrat19 Date: Sat, 12 Oct 2019 21:22:47 +0300 Subject: [PATCH] add loadBalancerIP option --- elasticsearch/README.md | 1 + elasticsearch/templates/service.yaml | 5 +++++ elasticsearch/tests/elasticsearch_test.py | 16 ++++++++++++++++ 3 files changed, 22 insertions(+) diff --git a/elasticsearch/README.md b/elasticsearch/README.md index e17a4d677..a0b4333c4 100644 --- a/elasticsearch/README.md +++ b/elasticsearch/README.md @@ -92,6 +92,7 @@ helm install --name elasticsearch elastic/elasticsearch --set imageTag=7.4.0 | `httpPort` | The http port that Kubernetes will use for the healthchecks and the service. If you change this you will also need to set [http.port](https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-http.html#_settings) in `extraEnvs` | `9200` | | `transportPort` | The transport port that Kubernetes will use for the service. If you change this you will also need to set [transport port configuration](https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-transport.html#_transport_settings) in `extraEnvs` | `9300` | | `service.type` | Type of elasticsearch service. [Service Types](https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types) | `ClusterIP` | +| `service.loadBalancerIP` | Some cloud providers allow you to specify the loadBalancerIP. In those cases, the load-balancer is created with the user-specified loadBalancerIP. If the loadBalancerIP field is not specified, the loadBalancer is set up with an ephemeral IP address. If you specify a loadBalancerIP but your cloud provider does not support the feature, the loadbalancerIP field that you set is ignored. [LoadBalancer options](https://kubernetes.io/docs/concepts/services-networking/service/#loadbalancer) | `` | | `service.nodePort` | Custom [nodePort](https://kubernetes.io/docs/concepts/services-networking/service/#nodeport) port that can be set if you are using `service.type: nodePort`. | `` | | `service.annotations` | Annotations that Kubernetes will use for the service. This will configure load balancer if `service.type` is `LoadBalancer` [Annotations](https://kubernetes.io/docs/concepts/services-networking/service/#ssl-support-on-aws) | `{}` | | `service.httpPortName` | The name of the http port within the service | `http` | diff --git a/elasticsearch/templates/service.yaml b/elasticsearch/templates/service.yaml index 0a89edb80..0ff36e26d 100644 --- a/elasticsearch/templates/service.yaml +++ b/elasticsearch/templates/service.yaml @@ -27,6 +27,11 @@ spec: - name: {{ .Values.service.transportPortName | default "transport" }} protocol: TCP port: {{ .Values.transportPort }} +{{- if .Values.service.loadBalancerIP }} + # enables you to choose a specific IP address for the load balancer. + # ignored if your cloud provider doesnt support that option + loadBalancerIP: {{ .Values.service.loadBalancerIP }} +{{- end }} --- kind: Service apiVersion: v1 diff --git a/elasticsearch/tests/elasticsearch_test.py b/elasticsearch/tests/elasticsearch_test.py index 4517c9fc7..9667a51ed 100755 --- a/elasticsearch/tests/elasticsearch_test.py +++ b/elasticsearch/tests/elasticsearch_test.py @@ -659,6 +659,22 @@ def test_adding_a_nodePort(): assert r['service'][uname]['spec']['ports'][0]['nodePort'] == 30001 +def test_adding_a_loadBalancerIP(): + config = '' + + r = helm_template(config) + + assert 'loadBalancerIP' not in r['service'][uname]['spec'] + + config = ''' + service: + loadBalancerIP: 10.12.19.98 + ''' + + r = helm_template(config) + + assert r['service'][uname]['spec']['loadBalancerIP'] == '10.12.19.98' + def test_master_termination_fixed_enabled(): config = ''