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:
@@ -0,0 +1,19 @@
|
||||
{{- if not .Open }}
|
||||
|
||||
---
|
||||
kind: NetworkPolicy
|
||||
apiVersion: networking.k8s.io/v1
|
||||
metadata:
|
||||
name: allow-dns-in-namespace
|
||||
namespace: {{ .Name }}
|
||||
spec:
|
||||
podSelector: {}
|
||||
policyTypes:
|
||||
- Egress
|
||||
egress:
|
||||
- ports:
|
||||
- port: 53
|
||||
protocol: TCP
|
||||
- port: 53
|
||||
protocol: UDP
|
||||
{{- end }}
|
||||
@@ -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 }}
|
||||
|
||||
Reference in New Issue
Block a user