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

Add support for labels on services #344

Merged
merged 3 commits into from
Oct 29, 2019
Merged
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
4 changes: 3 additions & 1 deletion elasticsearch/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ helm install --name elasticsearch elastic/elasticsearch --set imageTag=7.4.1
| `podManagementPolicy` | By default Kubernetes [deploys statefulsets serially](https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#pod-management-policies). This deploys them in parallel so that they can discover eachother | `Parallel` |
| `protocol` | The protocol that will be used for the readinessProbe. Change this to `https` if you have `xpack.security.http.ssl.enabled` set | `http` |
| `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` |
| `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.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.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) | `{}` |
Expand Down
6 changes: 6 additions & 0 deletions elasticsearch/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ metadata:
release: {{ .Release.Name | quote }}
chart: "{{ .Chart.Name }}"
app: "{{ template "uname" . }}"
{{- if .Values.service.labels }}
{{ toYaml .Values.service.labels | indent 4}}
{{- end }}
annotations:
{{ toYaml .Values.service.annotations | indent 4 }}
spec:
Expand Down Expand Up @@ -37,6 +40,9 @@ metadata:
release: {{ .Release.Name | quote }}
chart: "{{ .Chart.Name }}"
app: "{{ template "uname" . }}"
{{- if .Values.service.labelsHeadless }}
{{ toYaml .Values.service.labelsHeadless | indent 4 }}
{{- end }}
annotations:
service.alpha.kubernetes.io/tolerate-unready-endpoints: "true"
spec:
Expand Down
37 changes: 37 additions & 0 deletions elasticsearch/tests/elasticsearch_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,43 @@ def test_adding_a_nodePort():

assert r['service'][uname]['spec']['ports'][0]['nodePort'] == 30001


def test_adding_a_label_on_non_headless_service():
config = ''

r = helm_template(config)

assert 'label1' not in r['service'][uname]['metadata']['labels']

config = '''
service:
labels:
label1: value1
'''

r = helm_template(config)

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



def test_adding_a_label_on_headless_service():
config = ''

r = helm_template(config)

assert 'label1' not in r['service'][uname + '-headless']['metadata']['labels']

config = '''
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
2 changes: 2 additions & 0 deletions elasticsearch/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ httpPort: 9200
transportPort: 9300

service:
labels: {}
labelsHeadless: {}
type: ClusterIP
nodePort: ""
annotations: {}
Expand Down