Skip to content

Commit a04d630

Browse files
committed
chore(addons): modify networkpolicy config
1 parent c020fab commit a04d630

19 files changed

Lines changed: 162 additions & 19 deletions

File tree

addons/mariadb-1.1.0/chart/mariadb/templates/primary/networkpolicy-ingress.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,21 @@ spec:
1616
app.kubernetes.io/component: primary
1717
{{- include "common.labels.standard" . | nindent 6 }}
1818
ingress:
19+
{{- if or .Values.networkPolicy.allowCurrentNamespace .Values.networkPolicy.allowNamespaces }}
20+
- from:
21+
{{- if .Values.networkPolicy.allowCurrentNamespace }}
22+
- namespaceSelector:
23+
matchLabels:
24+
kubernetes.io/metadata.name: {{ .Release.Namespace }}
25+
{{- end }}
26+
{{- range $namespace := .Values.networkPolicy.allowNamespaces }}
27+
{{- if $namespace }}
28+
- namespaceSelector:
29+
matchLabels:
30+
kubernetes.io/metadata.name: {{ $namespace }}
31+
{{- end }}
32+
{{- end }}
33+
{{- end }}
1934
{{- if and .Values.metrics.enabled .Values.networkPolicy.metrics.enabled (or .Values.networkPolicy.metrics.namespaceSelector .Values.networkPolicy.metrics.podSelector) }}
2035
- from:
2136
{{- if .Values.networkPolicy.metrics.namespaceSelector }}

addons/mariadb-1.1.0/chart/mariadb/templates/secondary/networkpolicy-ingress.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,21 @@ spec:
1616
app.kubernetes.io/component: secondary
1717
{{- include "common.labels.standard" . | nindent 6 }}
1818
ingress:
19+
{{- if or .Values.networkPolicy.allowCurrentNamespace .Values.networkPolicy.allowNamespaces }}
20+
- from:
21+
{{- if .Values.networkPolicy.allowCurrentNamespace }}
22+
- namespaceSelector:
23+
matchLabels:
24+
kubernetes.io/metadata.name: {{ .Release.Namespace }}
25+
{{- end }}
26+
{{- range $namespace := .Values.networkPolicy.allowNamespaces }}
27+
{{- if $namespace }}
28+
- namespaceSelector:
29+
matchLabels:
30+
kubernetes.io/metadata.name: {{ $namespace }}
31+
{{- end }}
32+
{{- end }}
33+
{{- end }}
1934
{{- if and .Values.metrics.enabled .Values.networkPolicy.metrics.enabled (or .Values.networkPolicy.metrics.namespaceSelector .Values.networkPolicy.metrics.podSelector) }}
2035
- from:
2136
{{- if .Values.networkPolicy.metrics.namespaceSelector }}

addons/mariadb-1.1.0/chart/mariadb/values.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1166,11 +1166,13 @@ metrics:
11661166
networkPolicy:
11671167
## @param networkPolicy.enabled Enable network policies
11681168
##
1169-
enabled: false
1169+
enabled: true
11701170
## @param networkPolicy.metrics.enabled Enable network policy for metrics (prometheus)
11711171
## @param networkPolicy.metrics.namespaceSelector [object] Monitoring namespace selector labels. These labels will be used to identify the prometheus' namespace.
11721172
## @param networkPolicy.metrics.podSelector [object] Monitoring pod selector labels. These labels will be used to identify the Prometheus pods.
11731173
##
1174+
allowCurrentNamespace: true
1175+
allowNamespaces: []
11741176
metrics:
11751177
enabled: false
11761178
## e.g:

addons/minio-1.1.0/chart/minio/templates/networkpolicy.yaml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,18 @@ spec:
2626
{{ include "common.names.fullname" . }}-client: "true"
2727
- podSelector:
2828
matchLabels: {{- include "common.labels.matchLabels" . | nindent 14 }}
29-
29+
{{- if .Values.networkPolicy.allowCurrentNamespace }}
30+
- namespaceSelector:
31+
matchLabels:
32+
kubernetes.io/metadata.name: {{ .Release.Namespace }}
33+
{{- end }}
34+
{{- range $namespace := .Values.networkPolicy.allowNamespaces }}
35+
{{- if $namespace }}
36+
- namespaceSelector:
37+
matchLabels:
38+
kubernetes.io/metadata.name: {{ $namespace }}
39+
{{- end }}
40+
{{- end }}
3041
{{- if .Values.networkPolicy.extraFromClauses }}
3142
{{- toYaml .Values.networkPolicy.extraFromClauses | nindent 8 }}
3243
{{- end }}

addons/minio-1.1.0/chart/minio/values.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -837,12 +837,14 @@ apiIngress:
837837
networkPolicy:
838838
## @param networkPolicy.enabled Enable the default NetworkPolicy policy
839839
##
840-
enabled: false
840+
enabled: true
841841
## @param networkPolicy.allowExternal Don't require client label for connections
842842
## When set to false, only pods with the correct client label will have network access to the port MinIO® is
843843
## listening on. When true, MinIO® will accept connections from any source (with the correct destination port).
844844
##
845-
allowExternal: true
845+
allowExternal: false
846+
allowLocalNamespace: true
847+
allowNamespaces: []
846848
## @param networkPolicy.extraFromClauses Allows to add extra 'from' clauses to the NetworkPolicy
847849
extraFromClauses: {}
848850
## Example

addons/postgresql-1.1.0/chart/postgresql/templates/primary/networkpolicy.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,21 @@ spec:
1717
matchLabels: {{- include "common.labels.matchLabels" . | nindent 6 }}
1818
app.kubernetes.io/component: primary
1919
ingress:
20+
{{- if or .Values.networkPolicy.allowCurrentNamespace .Values.networkPolicy.allowNamespaces }}
21+
- from:
22+
{{- if .Values.networkPolicy.allowCurrentNamespace }}
23+
- namespaceSelector:
24+
matchLabels:
25+
kubernetes.io/metadata.name: {{ .Release.Namespace }}
26+
{{- end }}
27+
{{- range $namespace := .Values.networkPolicy.allowNamespaces }}
28+
{{- if $namespace }}
29+
- namespaceSelector:
30+
matchLabels:
31+
kubernetes.io/metadata.name: {{ $namespace }}
32+
{{- end }}
33+
{{- end }}
34+
{{- end }}
2035
{{- if and .Values.metrics.enabled .Values.networkPolicy.metrics.enabled (or .Values.networkPolicy.metrics.namespaceSelector .Values.networkPolicy.metrics.podSelector) }}
2136
- from:
2237
{{- if .Values.networkPolicy.metrics.namespaceSelector }}

addons/postgresql-1.1.0/chart/postgresql/templates/read/networkpolicy.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,21 @@ spec:
1717
matchLabels: {{- include "common.labels.matchLabels" . | nindent 6 }}
1818
app.kubernetes.io/component: read
1919
ingress:
20+
{{- if or .Values.networkPolicy.allowCurrentNamespace .Values.networkPolicy.allowNamespaces }}
21+
- from:
22+
{{- if .Values.networkPolicy.allowCurrentNamespace }}
23+
- namespaceSelector:
24+
matchLabels:
25+
kubernetes.io/metadata.name: {{ .Release.Namespace }}
26+
{{- end }}
27+
{{- range $namespace := .Values.networkPolicy.allowNamespaces }}
28+
{{- if $namespace }}
29+
- namespaceSelector:
30+
matchLabels:
31+
kubernetes.io/metadata.name: {{ $namespace }}
32+
{{- end }}
33+
{{- end }}
34+
{{- end }}
2035
{{- if and .Values.networkPolicy.ingressRules.readReplicasAccessOnlyFrom.enabled (or .Values.networkPolicy.ingressRules.readReplicasAccessOnlyFrom.namespaceSelector .Values.networkPolicy.ingressRules.readReplicasAccessOnlyFrom.podSelector) }}
2136
- from:
2237
{{- if .Values.networkPolicy.ingressRules.readReplicasAccessOnlyFrom.namespaceSelector }}

addons/postgresql-1.1.0/chart/postgresql/values.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -954,7 +954,9 @@ readReplicas:
954954
networkPolicy:
955955
## @param networkPolicy.enabled Enable network policies
956956
##
957-
enabled: false
957+
enabled: true
958+
allowLocalNamespace: true
959+
allowNamespaces: []
958960
## @param networkPolicy.metrics.enabled Enable network policies for metrics (prometheus)
959961
## @param networkPolicy.metrics.namespaceSelector [object] Monitoring namespace selector labels. These labels will be used to identify the prometheus' namespace.
960962
## @param networkPolicy.metrics.podSelector [object] Monitoring pod selector labels. These labels will be used to identify the Prometheus pods.

addons/rabbitmq-1.1.0/chart/rabbitmq/templates/networkpolicy.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,20 @@ spec:
3030
- podSelector:
3131
matchLabels:
3232
{{- include "common.labels.matchLabels" . | nindent 14 }}
33+
{{- if or .Values.networkPolicy.allowCurrentNamespace .Values.networkPolicy.allowNamespaces }}
34+
{{- if .Values.networkPolicy.allowCurrentNamespace }}
35+
- namespaceSelector:
36+
matchLabels:
37+
kubernetes.io/metadata.name: {{ .Release.Namespace }}
38+
{{- end }}
39+
{{- range $namespace := .Values.networkPolicy.allowNamespaces }}
40+
{{- if $namespace }}
41+
- namespaceSelector:
42+
matchLabels:
43+
kubernetes.io/metadata.name: {{ $namespace }}
44+
{{- end }}
45+
{{- end }}
46+
{{- end }}
3347
{{- if .Values.networkPolicy.additionalRules }}
3448
{{- include "common.tplvalues.render" (dict "value" .Values.networkPolicy.additionalRules "context" $) | nindent 8 }}
3549
{{- end }}

addons/rabbitmq-1.1.0/chart/rabbitmq/templates/statefulset.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ spec:
145145
preStop:
146146
exec:
147147
command:
148+
- init-stack
148149
- /bin/bash
149150
- -ec
150151
- |
@@ -277,6 +278,7 @@ spec:
277278
livenessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.livenessProbe "enabled") "context" $) | nindent 12 }}
278279
exec:
279280
command:
281+
- init-stack
280282
- /bin/bash
281283
- -ec
282284
- rabbitmq-diagnostics -q ping
@@ -287,6 +289,7 @@ spec:
287289
readinessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.readinessProbe "enabled") "context" $) | nindent 12 }}
288290
exec:
289291
command:
292+
- init-stack
290293
- /bin/bash
291294
- -ec
292295
- rabbitmq-diagnostics -q check_running && rabbitmq-diagnostics -q check_local_alarms

0 commit comments

Comments
 (0)