Skip to content

Commit 7676131

Browse files
committed
feat(redis-ha): Add tls ports to netpol if defined
Signed-off-by: OpenGuidou <guillaume.doussin@gmail.com>
1 parent 697cba5 commit 7676131

File tree

3 files changed

+93
-9
lines changed

3 files changed

+93
-9
lines changed

charts/redis-ha/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ keywords:
55
- redis
66
- keyvalue
77
- database
8-
version: 4.32.0
8+
version: 4.33.0
99
appVersion: 7.2.4
1010
description: This Helm chart provides a highly available Redis implementation with a master/slave configuration and uses Sentinel sidecars for failover management
1111
icon: https://upload.wikimedia.org/wikipedia/en/thumb/6/6b/Redis_Logo.svg/1200px-Redis_Logo.svg.png

charts/redis-ha/templates/redis-ha-network-policy.yaml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,22 @@ spec:
3131
release: {{ .Release.Name }}
3232
app: {{ template "redis-ha.name" . }}
3333
ports:
34+
{{- if ne (int .Values.redis.port) 0 }}
3435
- port: {{ .Values.redis.port }}
3536
protocol: TCP
37+
{{- end }}
38+
{{- if ne (int .Values.sentinel.port) 0 }}
3639
- port: {{ .Values.sentinel.port }}
3740
protocol: TCP
41+
{{- end }}
42+
{{- if ne (int .Values.redis.tlsPort) 0 }}
43+
- port: {{ .Values.redis.tlsPort }}
44+
protocol: TCP
45+
{{- end }}
46+
{{- if ne (int .Values.sentinel.tlsPort) 0 }}
47+
- port: {{ .Values.sentinel.tlsPort }}
48+
protocol: TCP
49+
{{- end }}
3850
{{- range $rule := .Values.networkPolicy.egressRules }}
3951
- to:
4052
{{ (tpl (toYaml $rule.selectors) $) | indent 7 }}
@@ -48,21 +60,45 @@ spec:
4860
release: {{ .Release.Name }}
4961
app: {{ template "redis-ha.name" . }}
5062
ports:
63+
{{- if ne (int .Values.redis.port) 0 }}
5164
- port: {{ .Values.redis.port }}
5265
protocol: TCP
66+
{{- end }}
67+
{{- if ne (int .Values.sentinel.port) 0 }}
5368
- port: {{ .Values.sentinel.port }}
5469
protocol: TCP
70+
{{- end }}
71+
{{- if ne (int .Values.redis.tlsPort) 0 }}
72+
- port: {{ .Values.redis.tlsPort }}
73+
protocol: TCP
74+
{{- end }}
75+
{{- if ne (int .Values.sentinel.tlsPort) 0 }}
76+
- port: {{ .Values.sentinel.tlsPort }}
77+
protocol: TCP
78+
{{- end }}
5579
{{- if .Values.haproxy.enabled }}
5680
- from:
5781
- podSelector:
5882
matchLabels:
5983
release: {{ .Release.Name }}
6084
app: {{ template "redis-ha.name" . }}-haproxy
6185
ports:
86+
{{- if ne (int .Values.redis.port) 0 }}
6287
- port: {{ .Values.redis.port }}
6388
protocol: TCP
89+
{{- end }}
90+
{{- if ne (int .Values.sentinel.port) 0 }}
6491
- port: {{ .Values.sentinel.port }}
6592
protocol: TCP
93+
{{- end }}
94+
{{- if ne (int .Values.redis.tlsPort) 0 }}
95+
- port: {{ .Values.redis.tlsPort }}
96+
protocol: TCP
97+
{{- end }}
98+
{{- if ne (int .Values.sentinel.tlsPort) 0 }}
99+
- port: {{ .Values.sentinel.tlsPort }}
100+
protocol: TCP
101+
{{- end }}
66102
{{- end }}
67103
{{- range $rule := .Values.networkPolicy.ingressRules }}
68104
- from:
@@ -71,10 +107,22 @@ spec:
71107
{{- if $rule.ports }}
72108
{{ toYaml $rule.ports | indent 7 }}
73109
{{- else }}
110+
{{- if ne (int .Values.redis.port) 0 }}
74111
- port: {{ $root.Values.redis.port }}
75112
protocol: TCP
113+
{{- end }}
114+
{{- if ne (int .Values.sentinel.port) 0 }}
76115
- port: {{ $root.Values.sentinel.port }}
77116
protocol: TCP
117+
{{- end }}
118+
{{- if ne (int .Values.redis.tlsPort) 0 }}
119+
- port: {{ .Values.redis.tlsPort }}
120+
protocol: TCP
121+
{{- end }}
122+
{{- if ne (int .Values.sentinel.tlsPort) 0 }}
123+
- port: {{ .Values.sentinel.tlsPort }}
124+
protocol: TCP
125+
{{- end }}
78126
{{- end }}
79127
{{- end }}
80128
{{- end }}

charts/redis-ha/templates/redis-haproxy-network-policy.yaml

Lines changed: 44 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,22 @@ spec:
3131
release: {{ .Release.Name }}
3232
app: {{ template "redis-ha.name" . }}
3333
ports:
34+
{{- if ne (int .Values.redis.port) 0 }}
3435
- port: {{ .Values.redis.port }}
3536
protocol: TCP
37+
{{- end }}
38+
{{- if ne (int .Values.sentinel.port) 0 }}
3639
- port: {{ .Values.sentinel.port }}
3740
protocol: TCP
41+
{{- end }}
42+
{{- if ne (int .Values.redis.tlsPort) 0 }}
43+
- port: {{ .Values.redis.tlsPort }}
44+
protocol: TCP
45+
{{- end }}
46+
{{- if ne (int .Values.sentinel.tlsPort) 0 }}
47+
- port: {{ .Values.sentinel.tlsPort }}
48+
protocol: TCP
49+
{{- end }}
3850
- to:
3951
- namespaceSelector: {}
4052
ports:
@@ -55,20 +67,44 @@ spec:
5567
release: {{ .Release.Name }}
5668
app: {{ template "redis-ha.name" . }}
5769
ports:
58-
- port: {{ .Values.redis.port }}
59-
protocol: TCP
60-
- port: {{ .Values.sentinel.port }}
61-
protocol: TCP
70+
{{- if ne (int .Values.redis.port) 0 }}
71+
- port: {{ .Values.redis.port }}
72+
protocol: TCP
73+
{{- end }}
74+
{{- if ne (int .Values.sentinel.port) 0 }}
75+
- port: {{ .Values.sentinel.port }}
76+
protocol: TCP
77+
{{- end }}
78+
{{- if ne (int .Values.redis.tlsPort) 0 }}
79+
- port: {{ .Values.redis.tlsPort }}
80+
protocol: TCP
81+
{{- end }}
82+
{{- if ne (int .Values.sentinel.tlsPort) 0 }}
83+
- port: {{ .Values.sentinel.tlsPort }}
84+
protocol: TCP
85+
{{- end }}
6286
{{- range $rule := .Values.haproxy.networkPolicy.ingressRules }}
6387
- from:
6488
{{- (tpl (toYaml $rule.selectors) $) | nindent 8 }}
6589
ports:
6690
{{- if $rule.ports }}
6791
{{- toYaml $rule.ports | nindent 8 }}
6892
{{- end }}
69-
- port: {{ $root.Values.redis.port }}
70-
protocol: TCP
71-
- port: {{ $root.Values.sentinel.port }}
72-
protocol: TCP
93+
{{- if ne (int .Values.redis.port) 0 }}
94+
- port: {{ .Values.redis.port }}
95+
protocol: TCP
96+
{{- end }}
97+
{{- if ne (int .Values.sentinel.port) 0 }}
98+
- port: {{ .Values.sentinel.port }}
99+
protocol: TCP
100+
{{- end }}
101+
{{- if ne (int .Values.redis.tlsPort) 0 }}
102+
- port: {{ .Values.redis.tlsPort }}
103+
protocol: TCP
104+
{{- end }}
105+
{{- if ne (int .Values.sentinel.tlsPort) 0 }}
106+
- port: {{ .Values.sentinel.tlsPort }}
107+
protocol: TCP
108+
{{ end }}
73109
{{- end }}
74110
{{- end }}

0 commit comments

Comments
 (0)