Skip to content

Commit cb49f7f

Browse files
authored
chore(mysql-cluster): modify networkpolicy (#8)
* chore(mysql-cluster): modify networkpolicy * fix(prometheus): fix typo
1 parent 1380cfe commit cb49f7f

6 files changed

Lines changed: 32 additions & 32 deletions

File tree

addons/mysql-cluster/8.0/chart/mysql-cluster/templates/networkpolicy.yaml

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,24 @@ spec:
2323
ingress:
2424
# Allow inbound connections
2525
- ports:
26-
- port: {{ .Values.primary.service.ports.mysql }}
27-
{{- if not .Values.networkPolicy.allowExternal }}
26+
- port: {{ .Values.router.service.portrw }}
27+
- port: {{ .Values.router.service.portro }}
28+
{{- if and .Values.metrics.enabled }}
29+
- port: {{ .Values.metrics.service.port }}
30+
{{ end }}
31+
{{- if or .Values.networkPolicy.allowCurrentNamespace .Values.networkPolicy.allowNamespaces }}
2832
from:
29-
- podSelector:
33+
{{- if .Values.networkPolicy.allowCurrentNamespace }}
34+
- namespaceSelector:
3035
matchLabels:
31-
{{ template "common.names.fullname" . }}-client: "true"
32-
{{- if .Values.networkPolicy.explicitNamespacesSelector }}
33-
namespaceSelector:
34-
{{ toYaml .Values.networkPolicy.explicitNamespacesSelector | indent 12 }}
35-
{{- end }}
36-
- podSelector:
36+
kubernetes.io/metadata.name: {{ .Release.Namespace }}
37+
{{- end }}
38+
{{- range $namespace := .Values.networkPolicy.allowNamespaces }}
39+
{{- if $namespace }}
40+
- namespaceSelector:
3741
matchLabels:
38-
{{- include "common.labels.matchLabels" . | nindent 14 }}
42+
kubernetes.io/metadata.name: {{ $namespace }}
3943
{{- end }}
40-
{{- if .Values.metrics.enabled }}
41-
# Allow prometheus scrapes
42-
- ports:
43-
- port: 9104
44-
{{- end }}
44+
{{- end }}
45+
{{- end }}
4546
{{- end }}

addons/mysql-cluster/8.0/chart/mysql-cluster/values.yaml

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -971,28 +971,16 @@ rbac:
971971
networkPolicy:
972972
## @param networkPolicy.enabled Enable creation of NetworkPolicy resources
973973
##
974-
enabled: false
974+
enabled: true
975975
## @param networkPolicy.allowExternal The Policy model to apply.
976976
## When set to false, only pods with the correct
977977
## client label will have network access to the port MySQL is listening
978978
## on. When true, MySQL will accept connections from any source
979979
## (with the correct destination port).
980980
##
981-
allowExternal: true
982-
## @param networkPolicy.explicitNamespacesSelector A Kubernetes LabelSelector to explicitly select namespaces from which ingress traffic could be allowed to MySQL
983-
## If explicitNamespacesSelector is missing or set to {}, only client Pods that are in the networkPolicy's namespace
984-
## and that match other criteria, the ones that have the good label, can reach the DB.
985-
## But sometimes, we want the DB to be accessible to clients from other namespaces, in this case, we can use this
986-
## LabelSelector to select these namespaces, note that the networkPolicy's namespace should also be explicitly added.
987-
##
988-
## Example:
989-
## explicitNamespacesSelector:
990-
## matchLabels:
991-
## role: frontend
992-
## matchExpressions:
993-
## - {key: role, operator: In, values: [frontend]}
994-
##
995-
explicitNamespacesSelector: {}
981+
allowCurrentNamespace: true
982+
allowNamespaces: []
983+
996984

997985
## @section Volume Permissions parameters
998986

@@ -1035,7 +1023,7 @@ volumePermissions:
10351023
metrics:
10361024
## @param metrics.enabled Start a side-car prometheus exporter
10371025
##
1038-
enabled: false
1026+
enabled: true
10391027
## @param metrics.image.registry Exporter image registry
10401028
## @param metrics.image.repository Exporter image repository
10411029
## @param metrics.image.tag Exporter image tag (immutable tags are recommended)
@@ -1132,6 +1120,17 @@ metrics:
11321120
## cpu: 100m
11331121
## memory: 256Mi
11341122
requests: {}
1123+
containerSecurityContext:
1124+
enabled: true
1125+
runAsUser: 1001
1126+
runAsGroup: 0
1127+
runAsNonRoot: true
1128+
allowPrivilegeEscalation: false
1129+
seccompProfile:
1130+
type: RuntimeDefault
1131+
capabilities:
1132+
drop:
1133+
- ALL
11351134
## Mysqld Prometheus exporter liveness probe
11361135
## ref: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#container-probes
11371136
## @param metrics.livenessProbe.enabled Enable livenessProbe
File renamed without changes.

addons/prometheus/2/plan/standard-1-2/create-instance-schema.json renamed to addons/prometheus/2/plans/standard-1-2/create-instance-schema.json

File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)