@@ -105,4 +105,179 @@ spec:
105105 {{- end }}
106106 policyTypes :
107107 - Egress
108- {{- end }}
108+ {{- end }}
109+ {{- if .Values.policies.networkPolicy.ingress.enabled }}
110+ ---
111+ apiVersion : networking.k8s.io/v1
112+ kind : NetworkPolicy
113+ metadata :
114+ name : vc-cp-{{ .Release.Name }}-ingress
115+ namespace : {{ .Release.Namespace }}
116+ labels :
117+ app : vcluster
118+ chart : " {{ include " vcluster.version.label" $ }}"
119+ release : " {{ .Release.Name }}"
120+ heritage : " {{ .Release.Service }}"
121+ {{- if .Values.policies.networkPolicy.labels }}
122+ {{ toYaml .Values.policies.networkPolicy.labels | indent 4 }}
123+ {{- end }}
124+ {{- $annotations := merge dict .Values.controlPlane.advanced.globalMetadata.annotations .Values.policies.networkPolicy.annotations }}
125+ {{- if $annotations }}
126+ annotations :
127+ {{ toYaml $annotations | indent 4 }}
128+ {{- end }}
129+ spec :
130+ podSelector :
131+ matchLabels :
132+ release : {{ .Release.Name }}
133+ policyTypes :
134+ - Ingress
135+ ingress :
136+ - ports :
137+ - port : 8443
138+ protocol : TCP
139+ from :
140+ # Allow for vcluster workloads traffic
141+ - podSelector :
142+ matchLabels :
143+ vcluster.loft.sh/managed-by : {{ .Release.Name }}
144+ {{- if .Values.policies.networkPolicy.ingress.platform }}
145+ # Allow ingress access from the loft platform.
146+ - podSelector :
147+ matchLabels :
148+ app : loft
149+ namespaceSelector : {}
150+ {{- end }}
151+
152+ {{- if .Values.policies.networkPolicy.ingress.controlPlaneRules }}
153+ {{ toYaml .Values.policies.networkPolicy.ingress.controlPlaneRules | indent 4 }}
154+ {{- end }}
155+ ---
156+ apiVersion : networking.k8s.io/v1
157+ kind : NetworkPolicy
158+ metadata :
159+ name : vc-kube-dns-{{ .Release.Name }}-ingress
160+ namespace : {{ .Release.Namespace }}
161+ labels :
162+ app : vcluster
163+ chart : " {{ include " vcluster.version.label" $ }}"
164+ release : " {{ .Release.Name }}"
165+ heritage : " {{ .Release.Service }}"
166+ {{- if .Values.policies.networkPolicy.labels }}
167+ {{ toYaml .Values.policies.networkPolicy.labels | indent 4 }}
168+ {{- end }}
169+ {{- $annotations := merge dict .Values.controlPlane.advanced.globalMetadata.annotations .Values.policies.networkPolicy.annotations }}
170+ {{- if $annotations }}
171+ annotations :
172+ {{ toYaml $annotations | indent 4 }}
173+ {{- end }}
174+ spec :
175+ podSelector :
176+ matchLabels :
177+ k8s-app : vcluster-kube-dns
178+ vcluster.loft.sh/managed-by : {{ .Release.Name }}
179+ policyTypes :
180+ - Ingress
181+ ingress :
182+ # Allows incoming connections to DNS server
183+ - ports :
184+ - port : 1053
185+ protocol : TCP
186+ - port : 1053
187+ protocol : UDP
188+ from :
189+ - podSelector :
190+ matchLabels :
191+ vcluster.loft.sh/managed-by : {{ .Release.Name }}
192+
193+ {{- if .Values.policies.networkPolicy.ingress.kubeDnsRules }}
194+ {{ toYaml .Values.policies.networkPolicy.ingress.kubeDnsRules | indent 4 }}
195+ {{- end }}
196+ ---
197+ apiVersion : networking.k8s.io/v1
198+ kind : NetworkPolicy
199+ metadata :
200+ name : vc-work-{{ .Release.Name }}-ingress
201+ namespace : {{ .Release.Namespace }}
202+ labels :
203+ app : vcluster
204+ chart : " {{ include " vcluster.version.label" $ }}"
205+ release : " {{ .Release.Name }}"
206+ heritage : " {{ .Release.Service }}"
207+ {{- if .Values.policies.networkPolicy.labels }}
208+ {{ toYaml .Values.policies.networkPolicy.labels | indent 4 }}
209+ {{- end }}
210+ {{- $annotations := merge dict .Values.controlPlane.advanced.globalMetadata.annotations .Values.policies.networkPolicy.annotations }}
211+ {{- if $annotations }}
212+ annotations :
213+ {{ toYaml $annotations | indent 4 }}
214+ {{- end }}
215+ spec :
216+ podSelector :
217+ matchLabels :
218+ vcluster.loft.sh/managed-by : {{ .Release.Name }}
219+ policyTypes :
220+ - Ingress
221+ ingress :
222+ - from :
223+ # Allow incoming connections from other vcluster workloads
224+ - podSelector :
225+ matchLabels :
226+ vcluster.loft.sh/managed-by : {{ .Release.Name }}
227+ {{- if .Values.policies.networkPolicy.ingress.workloadRules }}
228+ {{ toYaml .Values.policies.networkPolicy.ingress.workloadRules | indent 4 }}
229+ {{- end }}
230+ {{- if and .Values.controlPlane.backingStore.etcd.deploy.enabled .Values.controlPlane.backingStore.etcd.deploy.statefulSet.enabled }}
231+ ---
232+ apiVersion : networking.k8s.io/v1
233+ kind : NetworkPolicy
234+ metadata :
235+ name : vc-etcd-{{ .Release.Name }}-ingress
236+ namespace : {{ .Release.Namespace }}
237+ labels :
238+ app : vcluster
239+ chart : " {{ include " vcluster.version.label" $ }}"
240+ release : " {{ .Release.Name }}"
241+ heritage : " {{ .Release.Service }}"
242+ {{- if .Values.policies.networkPolicy.labels }}
243+ {{ toYaml .Values.policies.networkPolicy.labels | indent 4 }}
244+ {{- end }}
245+ {{- $annotations := merge dict .Values.controlPlane.advanced.globalMetadata.annotations .Values.policies.networkPolicy.annotations }}
246+ {{- if $annotations }}
247+ annotations :
248+ {{ toYaml $annotations | indent 4 }}
249+ {{- end }}
250+ spec :
251+ podSelector :
252+ matchLabels :
253+ app : vcluster-etcd
254+ release : {{ .Release.Name }}
255+ policyTypes :
256+ - Ingress
257+ ingress :
258+ - ports :
259+ - port : 2380
260+ protocol : TCP
261+ from :
262+ # Allow for vc-etcd peer traffic
263+ - podSelector :
264+ matchLabels :
265+ app : vcluster-etcd
266+ release : {{ .Release.Name }}
267+ - ports :
268+ - port : 2379
269+ protocol : TCP
270+ from :
271+ # Allow for vc-cp traffic
272+ - podSelector :
273+ matchLabels :
274+ app : vcluster
275+ release : {{ .Release.Name }}
276+
277+ # Allow for vc-etcd peer traffic
278+ - podSelector :
279+ matchLabels :
280+ app : vcluster-etcd
281+ release : {{ .Release.Name }}
282+ {{- end }}
283+ {{- end }}
0 commit comments