Skip to content

Commit

Permalink
LoadBalancer svc type and sticky sessions
Browse files Browse the repository at this point in the history
  • Loading branch information
laszlocph committed Apr 28, 2021
1 parent 5012c4a commit 27698ed
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
8 changes: 7 additions & 1 deletion charts/onechart/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ metadata:
labels:
{{- include "helm-chart.labels" . | nindent 4 }}
spec:
type: {{ if .Values.nodePortEnabled }}NodePort{{ else }}ClusterIP{{ end }}
type: {{ if .Values.nodePortEnabled }}NodePort{{ else if .Values.loadbalancerEnabled }}LoadBalancer{{ else }}ClusterIP{{ end }}
{{- if .Values.stickySessions }}
sessionAffinityConfig:
clientIP:
timeoutSeconds: 10800
externalTrafficPolicy: Local
{{- end }}
ports:
{{- if not .Values.ports }}
- port: {{ if .Values.svcPort }}{{ .Values.svcPort }}{{ else }}{{ .Values.containerPort }}{{ end }}
Expand Down
11 changes: 11 additions & 0 deletions charts/onechart/tests/service_sticky_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
suite: test deployment
templates:
- service.yaml
tests:
- it: Should set NodePort if flag enabled
set:
stickySessions: true
asserts:
- equal:
path: spec.externalTrafficPolicy
value: Local
7 changes: 7 additions & 0 deletions charts/onechart/tests/service_type_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,10 @@ tests:
- equal:
path: spec.type
value: NodePort
- it: Should set LoadBalancer if flag enabled
set:
loadbalancerEnabled: true
asserts:
- equal:
path: spec.type
value: LoadBalancer

0 comments on commit 27698ed

Please sign in to comment.