fixed issues with schema of network policy

also fixed encoding of matahLabels. Now using json format so that it
also works for empty maps.
This commit is contained in:
2025-01-03 00:10:32 +01:00
parent d85baf3beb
commit b8dfaa55a4
6 changed files with 40 additions and 10 deletions
+5 -4
View File
@@ -8,9 +8,10 @@
{{- end }}
{{- define "peers" }}
{{- range .Applications }}
- {{.Rule}}:
# {{ .Application.Namespace.Name }}/{{ .Application.Name }}
- podSelector:
matchLabels: {{ .Application.MatchLabels | toYaml | nindent 12 }}
matchLabels: {{ .Application.MatchLabels | toJson }}
namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: {{ .Application.Namespace.Name }}
@@ -22,6 +23,7 @@
{{- end }}
{{- define "networks" }}
{{- range .Networks }}
- {{.Rule}}:
# {{ .Network.Name }}
- ipBlock:
cidr: {{ .Network.CIDR}}
@@ -46,7 +48,8 @@ metadata:
labels: {{ .labels | toYaml | nindent 4 }}
spec:
# {{ .app.Namespace.Name }}/{{ .app.Name }}
podSelector: {{ .app.MatchLabels | toYaml | nindent 4 }}
podSelector:
matchLabels: {{ .app.MatchLabels | toJson }}
policyTypes:
{{- if or .ingress.Applications .ingress.Networks }}
- Ingress
@@ -57,14 +60,12 @@ spec:
{{- if or .ingress.Applications .ingress.Networks }}
ingress:
from:
{{- template "peers" .ingress }}
{{- template "networks" .ingress }}
{{- end }}
{{- if or .egress.Applications .egress.Networks }}
egress:
to:
{{- template "peers" .egress }}
{{- template "networks" .egress }}
{{- end }}