Skip to content

Commit aac031e

Browse files
authored
Merge pull request #291 from sandesvitor/feat/include_api_client_services
Allow "external" st2api, st2auth, and st2stream Services (LoadBalancer type with hostname)
2 parents 181f448 + d73f938 commit aac031e

File tree

5 files changed

+123
-5
lines changed

5 files changed

+123
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* New feature: Add `extra_volumes` to all python-based st2 deployments. This can facilitate changing log levels by loading logging conf file(s) from a custom ConfigMap. (#276) (by @cognifloyd)
77
* Initialize basic unittest infrastructure using `helm-unittest`. Added tests for labels, custom annotations, SecurityContext, pullSecrets, pullPolicy, Resources, nodeSelector, tolerations, affinity, dnsPolicy, dnsConfig, ServiceAccount attach, postStartScript, and both sensor-modes. (#284, #288)
88
* Allow partitioning sensors using the hash_range strategy instead of one sensor per pod. (#218) (by @cognifloyd)
9+
* New feature to include possibility for external services in st2api, st2stream and st2auth, setting default value for this services as `ClusterIP` and `hostname: ""`. Also, added new entry for custom_annotations_test.yaml and created new unit test services_test.yaml. (by @sandesvitor)
910

1011
## v0.80.0
1112
* Switch st2 to `v3.6` as a new default stable version (#274)

templates/services.yaml

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ metadata:
55
name: {{ .Release.Name }}-st2auth
66
annotations:
77
description: StackStorm st2auth - all authentication is managed by this service.
8+
{{- if .Values.st2auth.service.hostname }}
9+
external-dns.alpha.kubernetes.io/hostname: {{ .Values.st2auth.service.hostname | quote }}
10+
{{- end }}
11+
{{- if .Values.st2auth.service.annotations }}
12+
{{- toYaml .Values.st2auth.service.annotations | nindent 4 }}
13+
{{- end }}
814
labels:
915
app: st2auth
1016
tier: backend
@@ -16,7 +22,12 @@ spec:
1622
selector:
1723
app: st2auth
1824
release: {{ .Release.Name }}
19-
type: ClusterIP
25+
type: {{ .Values.st2auth.service.type }}
26+
{{- if contains "ExternalName" .Values.st2auth.service.type }}
27+
{{- if .Values.st2auth.service.hostname }}
28+
externalName: {{ .Values.st2auth.service.hostname }}
29+
{{- end }}
30+
{{- end }}
2031
ports:
2132
- protocol: TCP
2233
port: 9100
@@ -28,6 +39,12 @@ metadata:
2839
name: {{ .Release.Name }}-st2api
2940
annotations:
3041
description: StackStorm st2api - service hosts the REST API endpoints that serve requests from WebUI, CLI, ChatOps and other st2 services.
42+
{{- if .Values.st2api.service.hostname }}
43+
external-dns.alpha.kubernetes.io/hostname: {{ .Values.st2api.service.hostname | quote }}
44+
{{- end }}
45+
{{- if .Values.st2api.service.annotations }}
46+
{{- toYaml .Values.st2api.service.annotations | nindent 4 }}
47+
{{- end }}
3148
labels:
3249
app: st2api
3350
tier: backend
@@ -39,7 +56,12 @@ spec:
3956
selector:
4057
app: st2api
4158
release: {{ .Release.Name }}
42-
type: ClusterIP
59+
type: {{ .Values.st2api.service.type }}
60+
{{- if contains "ExternalName" .Values.st2api.service.type }}
61+
{{- if .Values.st2api.service.hostname }}
62+
externalName: {{ .Values.st2api.service.hostname }}
63+
{{- end }}
64+
{{- end }}
4365
ports:
4466
- protocol: TCP
4567
port: 9101
@@ -51,6 +73,12 @@ metadata:
5173
name: {{ .Release.Name }}-st2stream
5274
annotations:
5375
description: StackStorm st2stream - exposes a server-sent event stream, used by the clients like WebUI and ChatOps to receive update from the st2stream server.
76+
{{- if .Values.st2stream.service.hostname }}
77+
external-dns.alpha.kubernetes.io/hostname: {{ .Values.st2stream.service.hostname | quote }}
78+
{{- end }}
79+
{{- if .Values.st2stream.service.annotations }}
80+
{{- toYaml .Values.st2stream.service.annotations | nindent 4 }}
81+
{{- end }}
5482
labels:
5583
app: st2stream
5684
tier: backend
@@ -62,7 +90,12 @@ spec:
6290
selector:
6391
app: st2stream
6492
release: {{ .Release.Name }}
65-
type: ClusterIP
93+
type: {{ .Values.st2stream.service.type }}
94+
{{- if contains "ExternalName" .Values.st2stream.service.type }}
95+
{{- if .Values.st2stream.service.hostname }}
96+
externalName: {{ .Values.st2stream.service.hostname }}
97+
{{- end }}
98+
{{- end }}
6699
ports:
67100
- protocol: TCP
68101
port: 9102

tests/unit/custom_annotations_test.yaml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,27 @@ tests:
5252

5353
# st2auth, st2api, st2stream services do not accept custom annotations
5454

55-
- it: st2web Service accepts custom annotations
55+
- it: st2web, st2auth, st2api and st2stream Services accept custom annotations
5656
template: services.yaml
57-
documentIndex: 3
5857
set:
5958
st2web:
6059
service:
6160
hostname: some-host-name
6261
annotations: *annotations
62+
st2api:
63+
service:
64+
hostname: some-host-name
65+
annotations: *annotations
66+
st2auth:
67+
service:
68+
hostname: some-host-name
69+
annotations: *annotations
70+
st2stream:
71+
service:
72+
hostname: some-host-name
73+
annotations: *annotations
74+
st2chatops:
75+
enabled: false # exclude st2chatops to only test other services
6376
asserts: *annotations_asserts
6477

6578
# st2chatops service does not accept custom annotations

tests/unit/services_test.yaml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
suite: Services
3+
templates:
4+
# primary template files
5+
- services.yaml
6+
7+
tests:
8+
- it: st2web, st2auth, st2api, st2stream should work without externalName
9+
set:
10+
st2chatops:
11+
enabled: false
12+
asserts:
13+
- hasDocuments:
14+
count: 4
15+
- isNull:
16+
path: spec.externalName
17+
18+
- it: st2web, st2auth, st2api, st2stream should work with externalName if type is ExternalName
19+
set:
20+
st2web:
21+
service:
22+
hostname: some-host-name
23+
type: ExternalName
24+
st2auth:
25+
service:
26+
hostname: some-host-name
27+
type: ExternalName
28+
st2api:
29+
service:
30+
hostname: some-host-name
31+
type: ExternalName
32+
st2stream:
33+
service:
34+
hostname: some-host-name
35+
type: ExternalName
36+
st2chatops:
37+
enabled: false
38+
asserts:
39+
- hasDocuments:
40+
count: 4
41+
- equal:
42+
path: spec.type
43+
value: ExternalName
44+
- equal:
45+
path: spec.externalName
46+
value: some-host-name
47+

values.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,14 @@ st2auth:
348348
affinity: {}
349349
env: {}
350350
# HTTP_PROXY: http://proxy:1234
351+
service:
352+
# type can be one of "ClusterIP", "NodePort", "LoadBalancer" or "ExternalName"
353+
type: "ClusterIP"
354+
# The hostname associated with st2auth service (externalName, added to external DNS, etc.)
355+
hostname: ""
356+
# For more information regarding annotations, see
357+
# https://kubernetes.io/docs/concepts/services-networking/service/#ssl-support-on-aws
358+
annotations: {}
351359
serviceAccount:
352360
attach: false
353361
# postStartScript is optional. It has the contents of a bash script.
@@ -378,6 +386,14 @@ st2api:
378386
tolerations: []
379387
affinity: {}
380388
env: {}
389+
service:
390+
# type can be one of "ClusterIP", "NodePort", "LoadBalancer" or "ExternalName"
391+
type: "ClusterIP"
392+
# The hostname associated with st2api service (externalName, added to external DNS, etc.)
393+
hostname: ""
394+
# For more information regarding annotations, see
395+
# https://kubernetes.io/docs/concepts/services-networking/service/#ssl-support-on-aws
396+
annotations: {}
381397
# HTTP_PROXY: http://proxy:1234
382398
serviceAccount:
383399
attach: false
@@ -410,6 +426,14 @@ st2stream:
410426
affinity: {}
411427
env: {}
412428
# HTTP_PROXY: http://proxy:1234
429+
service:
430+
# type can be one of "ClusterIP", "NodePort", "LoadBalancer" or "ExternalName"
431+
type: "ClusterIP"
432+
# The hostname associated with st2api service (externalName, added to external DNS, etc.)
433+
hostname: ""
434+
# For more information regarding annotations, see
435+
# https://kubernetes.io/docs/concepts/services-networking/service/#ssl-support-on-aws
436+
annotations: {}
413437
serviceAccount:
414438
attach: false
415439
# postStartScript is optional. It has the contents of a bash script.

0 commit comments

Comments
 (0)