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

add loadBalancerIP field #323

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions elasticsearch/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ helm install --name elasticsearch elastic/elasticsearch --set imageTag=7.4.1
| `service.labels` | Labels to be added to non-headless service | `{}` |
| `service.labelsHeadless` | Labels to be added to headless service | `{}` |
| `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` |
Expand Down
5 changes: 5 additions & 0 deletions elasticsearch/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,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
Expand Down
16 changes: 15 additions & 1 deletion elasticsearch/tests/elasticsearch_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,19 @@ def test_adding_a_nodePort():
assert r['service'][uname]['spec']['ports'][0]['nodePort'] == 30001


def test_adding_a_loadBalancerIP():
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_adding_a_label_on_non_headless_service():
config = ''

Expand Down Expand Up @@ -704,11 +717,12 @@ def test_adding_a_label_on_headless_service():
labelsHeadless:
label1: value1
'''

r = helm_template(config)

assert r['service'][uname + '-headless']['metadata']['labels']['label1'] == 'value1'


def test_master_termination_fixed_enabled():
config = ''

Expand Down