1+ {{- /*
2+ Copyright Drycc Community.
3+ SPDX-License-Identifier : APACHE-2.0
4+ */}}
5+
6+ {{- if .Values.jobmanager.networkPolicy.enabled }}
7+ kind : NetworkPolicy
8+ apiVersion : {{ include "common.capabilities.networkPolicy.apiVersion" . }}
9+ metadata :
10+ name : {{ template "flink.jobmanager.fullname" . }}
11+ namespace : {{ include "common.names.namespace" . | quote }}
12+ labels : {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
13+ app.kubernetes.io/part-of : flink
14+ app.kubernetes.io/component : jobmanager
15+ {{- if .Values.commonAnnotations }}
16+ annotations : {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
17+ {{- end }}
18+ spec :
19+ {{- $podLabels := include "common.tplvalues.merge" ( dict "values" ( list .Values.jobmanager.podLabels .Values.commonLabels ) "context" . ) }}
20+ podSelector :
21+ matchLabels : {{- include "common.labels.matchLabels" ( dict "customLabels" $podLabels "context" $ ) | nindent 6 }}
22+ app.kubernetes.io/part-of : flink
23+ app.kubernetes.io/component : jobmanager
24+ policyTypes :
25+ - Ingress
26+ - Egress
27+ {{- if .Values.jobmanager.networkPolicy.allowExternalEgress }}
28+ egress :
29+ - {}
30+ {{- else }}
31+ egress :
32+ - ports :
33+ # Allow dns resolution
34+ - port : 53
35+ protocol : UDP
36+ - port : 53
37+ protocol : TCP
38+ # Allow outbound connections to other jobmanager pods
39+ - ports :
40+ - port : {{ .Values.jobmanager.containerPorts.blob }}
41+ - port : {{ .Values.jobmanager.containerPorts.rpc }}
42+ - port : {{ .Values.jobmanager.containerPorts.http }}
43+ to :
44+ - podSelector :
45+ matchLabels : {{- include "common.labels.matchLabels" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 14 }}
46+ app.kubernetes.io/part-of : flink
47+ app.kubernetes.io/component : jobmanager
48+ # Allow outbound connections to other taskmanager pods
49+ - ports :
50+ - port : {{ .Values.taskmanager.containerPorts.data }}
51+ - port : {{ .Values.taskmanager.containerPorts.rpc }}
52+ to :
53+ - podSelector :
54+ matchLabels : {{- include "common.labels.matchLabels" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 14 }}
55+ app.kubernetes.io/part-of : flink
56+ app.kubernetes.io/component : taskmanager
57+ {{- if .Values.jobmanager.networkPolicy.extraEgress }}
58+ {{- include "common.tplvalues.render" ( dict "value" .Values.jobmanager.networkPolicy.extraEgress "context" $ ) | nindent 4 }}
59+ {{- end }}
60+ {{- end }}
61+ ingress :
62+ - ports :
63+ - port : {{ .Values.jobmanager.containerPorts.blob }}
64+ - port : {{ .Values.jobmanager.containerPorts.rpc }}
65+ - port : {{ .Values.jobmanager.containerPorts.http }}
66+ {{- if not .Values.jobmanager.networkPolicy.allowExternal }}
67+ from :
68+ - podSelector :
69+ matchLabels : {{- include "common.labels.matchLabels" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 14 }}
70+ - podSelector :
71+ matchLabels :
72+ {{ template "flink.jobmanager.fullname" . }}-client: "true"
73+ {{- if .Values.jobmanager.networkPolicy.ingressNSMatchLabels }}
74+ - namespaceSelector :
75+ matchLabels :
76+ {{- range $key, $value := .Values.jobmanager.networkPolicy.ingressNSMatchLabels }}
77+ {{ $key | quote }}: {{ $value | quote }}
78+ {{- end }}
79+ {{- if .Values.jobmanager.networkPolicy.ingressNSPodMatchLabels }}
80+ podSelector :
81+ matchLabels :
82+ {{- range $key, $value := .Values.jobmanager.networkPolicy.ingressNSPodMatchLabels }}
83+ {{ $key | quote }}: {{ $value | quote }}
84+ {{- end }}
85+ {{- end }}
86+ {{- end }}
87+ - podSelector :
88+ matchLabels : {{- include "common.labels.matchLabels" ( dict "customLabels" $podLabels "context" $ ) | nindent 14 }}
89+ app.kubernetes.io/part-of : flink
90+ {{- end }}
91+ {{- if .Values.jobmanager.networkPolicy.extraIngress }}
92+ {{- include "common.tplvalues.render" ( dict "value" .Values.jobmanager.networkPolicy.extraIngress "context" $ ) | nindent 4 }}
93+ {{- end }}
94+ {{- end }}
0 commit comments