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

Commit

Permalink
Merge pull request #161 from elastic/porting_the_node_port
Browse files Browse the repository at this point in the history
[elasticsearch] Add configurable nodePort to service spec
  • Loading branch information
Crazybus authored Jun 13, 2019
2 parents e71376c + 22c3440 commit 4cef518
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
3 changes: 2 additions & 1 deletion elasticsearch/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ helm install --name elasticsearch elastic/elasticsearch --version 7.1.1 --set im
| `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.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) | `{}` |
| `updateStrategy` | The [updateStrategy](https://kubernetes.io/docs/tutorials/stateful-application/basic-stateful-set/#updating-statefulsets) for the statefulset. By default Kubernetes will wait for the cluster to be green after upgrading each pod. Setting this to `OnDelete` will allow you to manually delete each pod during upgrades | `RollingUpdate` |
| `maxUnavailable` | The [maxUnavailable](https://kubernetes.io/docs/tasks/run-application/configure-pdb/#specifying-a-poddisruptionbudget) value for the pod disruption budget. By default this will prevent Kubernetes from having more than 1 unhealthy pod in the node group | `1` |
Expand All @@ -102,7 +103,7 @@ helm install --name elasticsearch elastic/elasticsearch --version 7.1.1 --set im
| `nodeSelector` | Configurable [nodeSelector](https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#nodeselector) so that you can target specific nodes for your Elasticsearch cluster | `{}` |
| `tolerations` | Configurable [tolerations](https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/) | `[]` |
| `ingress` | Configurable [ingress](https://kubernetes.io/docs/concepts/services-networking/ingress/) to expose the Elasticsearch service. See [`values.yaml`](./values.yaml) for an example | `enabled: false` |
| `schedulerName` | Name of the [alternate scheduler](https://kubernetes.io/docs/tasks/administer-cluster/configure-multiple-schedulers/#specify-schedulers-for-pods) | `nil` |
| `schedulerName` | Name of the [alternate scheduler](https://kubernetes.io/docs/tasks/administer-cluster/configure-multiple-schedulers/#specify-schedulers-for-pods) | `nil` |

## Try it out

Expand Down
3 changes: 3 additions & 0 deletions elasticsearch/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ spec:
- name: http
protocol: TCP
port: {{ .Values.httpPort }}
{{- if .Values.service.nodePort }}
nodePort: {{ .Values.service.nodePort }}
{{- end }}
- name: transport
protocol: TCP
port: {{ .Values.transportPort }}
Expand Down
17 changes: 17 additions & 0 deletions elasticsearch/tests/elasticsearch_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -584,3 +584,20 @@ def test_scheduler_name():
'''
r = helm_template(config)
assert r['statefulset'][uname]['spec']['template']['spec']['schedulerName'] == "stork"


def test_adding_a_nodePort():
config = ''

r = helm_template(config)

assert 'nodePort' not in r['service'][uname]['spec']['ports'][0]

config = '''
service:
nodePort: 30001
'''

r = helm_template(config)

assert r['service'][uname]['spec']['ports'][0]['nodePort'] == 30001
1 change: 1 addition & 0 deletions elasticsearch/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ transportPort: 9300

service:
type: ClusterIP
nodePort:
annotations: {}

updateStrategy: RollingUpdate
Expand Down

0 comments on commit 4cef518

Please sign in to comment.