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

Commit

Permalink
[logstash] manage services for inputs implementing a listener
Browse files Browse the repository at this point in the history
  • Loading branch information
jmlrt committed Oct 21, 2019
1 parent f5f4d3b commit 68a85c0
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 3 deletions.
23 changes: 23 additions & 0 deletions logstash/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{{- if .Values.service }}
---
kind: Service
apiVersion: v1
metadata:
name: "{{ template "fullname" . }}"
labels:
app: "{{ template "fullname" . }}"
chart: "{{ .Chart.Name }}"
heritage: {{ .Release.Service | quote }}
release: {{ .Release.Name | quote }}
annotations:
{{ toYaml .Values.service.annotations | indent 4 }}
spec:
type: {{ .Values.service.type }}
selector:
app: "{{ template "fullname" . }}"
chart: "{{ .Chart.Name }}"
heritage: {{ .Release.Service | quote }}
release: {{ .Release.Name | quote }}
ports:
{{ toYaml .Values.service.ports | indent 4 }}
{{- end }}
3 changes: 3 additions & 0 deletions logstash/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ metadata:
{{ $key }}: {{ $value | quote }}
{{- end }}
spec:
{{- if .Values.service }}
serviceName: {{ template "fullname" . }}
{{- end }}
selector:
matchLabels:
app: "{{ template "fullname" . }}"
Expand Down
29 changes: 26 additions & 3 deletions logstash/tests/logstash_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ def test_defaults():
assert '/' in c['readinessProbe']['httpGet']['path']
assert 'http' in c['readinessProbe']['httpGet']['port']


# Resources
assert c['resources'] == {
'requests': {
Expand All @@ -90,6 +89,11 @@ def test_defaults():
assert 'volumeClaimTemplates' not in r['statefulset'][name]['spec']
assert r['statefulset'][name]['spec']['template']['spec']['containers'][0]['volumeMounts'] == None

# Service
assert 'serviceName' not in r['statefulset'][name]['spec']
assert 'service' not in r


# Other
assert r['statefulset'][name]['spec']['template']['spec']['securityContext'] == {
'fsGroup': 1000,
Expand All @@ -104,8 +108,6 @@ def test_defaults():
assert 'imagePullSecrets' not in r['statefulset'][name]['spec']['template']['spec']
assert 'tolerations' not in r['statefulset'][name]['spec']['template']['spec']
assert 'nodeSelector' not in r['statefulset'][name]['spec']['template']['spec']
assert 'service' not in r
assert 'ingress' not in r


def test_increasing_the_replicas():
Expand Down Expand Up @@ -547,3 +549,24 @@ def test_external_service_account():
# When referencing an external service account we do not want any resources to be created.
for resource in resources:
assert resource not in r


def test_adding_a_service():
config = '''
service:
annotations: {}
type: ClusterIP
ports:
- name: beats
port: 5044
protocol: TCP
targetPort: 5044
'''
r = helm_template(config)
s = r['service'][name]
assert s['metadata']['name'] == name
assert s['metadata']['annotations'] == None
assert s['spec']['type'] == 'ClusterIP'
assert len(s['spec']['ports']) == 1
assert s['spec']['ports'][0] == {
'name': 'beats', 'port': 5044, 'protocol': 'TCP', 'targetPort': 5044}
13 changes: 13 additions & 0 deletions logstash/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -184,3 +184,16 @@ lifecycle: {}
# postStart:
# exec:
# command: ["/bin/sh", "-c", "echo Hello from the postStart handler > /usr/share/message"]

service: {}
# annotations: {}
# type: ClusterIP
# ports:
# - name: beats
# port: 5044
# protocol: TCP
# targetPort: 5044
# - name: http
# port: 8080
# protocol: TCP
# targetPort: 8080

0 comments on commit 68a85c0

Please sign in to comment.