Skip to content

Commit a42d955

Browse files
committed
Fix load balancer traffic policy
This makes two changes: First, it upgrades the syntax to use newer version of the external traffic policy. This is based on testing on my Kubernetes 1.15 cluster, and was discovered from [this reference](kubernetes/ingress-nginx#1924) Second, it makes the non-load-balancer case switch to Cluster policy, which is necessary to allow the cluster to route NodePort traffic without a Kubernetes load balancer Also, fixed tiny whitespace nit
1 parent 4b2cc5a commit a42d955

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

charts/docker-mailserver/templates/service.yaml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ metadata:
1111
prometheus.io/path: {{ .Values.monitoring.service.path | quote }}
1212
prometheus.io/port: {{ .Values.monitoring.service.port | quote }}
1313
##
14-
## If a load balancer is being used, ensure that the newer type of LB that passes along IP information is used
15-
## rather than the legacy one.
16-
{{- if eq .Values.service.type "LoadBalancer" }}service.beta.kubernetes.io/external-traffic: "OnlyLocal"{{ end }}
1714
{{- if .Values.service.annotations }}
1815
{{ toYaml .Values.service.annotations | indent 2 }}
1916
{{ end }}
@@ -24,6 +21,13 @@ metadata:
2421
release: "{{ .Release.Name }}"
2522
name: {{ template "dockermailserver.fullname" . }}
2623
spec:
24+
## If a load balancer is being used, ensure that the newer type of LB that passes along IP information is used
25+
## rather than the legacy one.
26+
{{- if eq .Values.service.type "LoadBalancer" }}
27+
externalTrafficPolicy: Local
28+
{{ else }}
29+
externalTrafficPolicy: Cluster
30+
{{ end }}
2731
selector:
2832
app: {{ template "dockermailserver.fullname" . }}
2933
release: "{{ .Release.Name }}"
@@ -87,8 +91,7 @@ spec:
8791
loadBalancerIP: {{ .Values.service.loadBalancer.publicIp }}
8892
{{ if .Values.service.loadBalancer.allowedIps -}}
8993
loadBalancerSourceRanges:
90-
{{ .Values.service.loadBalancer.allowedIps | toYaml | indent 4 }}
94+
{{ .Values.service.loadBalancer.allowedIps | toYaml | indent 4 }}
9195
{{ end -}}
9296
{{ end -}}
9397
{{ end }}
94-
externalTrafficPolicy: Local

0 commit comments

Comments
 (0)