blob: 327e1fa37ff9a53044a19a588b75ed69f3d07424 [file] [log] [blame]
Sketch🕴️620d57b2025-07-31 22:31:14 +04001{{- /*
2Copyright Broadcom, Inc. All Rights Reserved.
3SPDX-License-Identifier: APACHE-2.0
4*/}}
5
6{{- if .Values.networkPolicy.enabled }}
7kind: NetworkPolicy
8apiVersion: {{ include "common.capabilities.networkPolicy.apiVersion" . }}
9metadata:
10 name: {{ template "common.names.fullname" . }}
11 namespace: {{ include "common.names.namespace" . | quote }}
12 labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
13 {{- if .Values.commonAnnotations }}
14 annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
15 {{- end }}
16spec:
17 {{- $podLabels := include "common.tplvalues.merge" ( dict "values" ( list .Values.podLabels .Values.commonLabels ) "context" . ) }}
18 podSelector:
19 matchLabels: {{- include "common.labels.matchLabels" ( dict "customLabels" $podLabels "context" $ ) | nindent 6 }}
20 policyTypes:
21 - Ingress
22 - Egress
23 egress:
24 {{- if .Values.networkPolicy.allowExternalEgress }}
25 - {}
26 {{- else }}
27 - ports:
28 # Allow dns resolution
29 - port: 53
30 protocol: UDP
31 - port: 53
32 protocol: TCP
33 {{- if .Values.networkPolicy.extraEgress }}
34 {{- include "common.tplvalues.render" ( dict "value" .Values.networkPolicy.extraEgress "context" $ ) | nindent 4 }}
35 {{- end }}
36 {{- end }}
37 ingress:
38 - ports:
39 - port: {{ .Values.containerPorts.http }}
40 {{- if .Values.containerPorts.https }}
41 - port: {{ .Values.containerPorts.https }}
42 {{- end }}
43 {{- if .Values.metrics.enabled }}
44 - port: {{ .Values.metrics.containerPorts.metrics }}
45 {{- end }}
46 {{- if not .Values.networkPolicy.allowExternal }}
47 from:
48 - podSelector:
49 matchLabels: {{- include "common.labels.matchLabels" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 14 }}
50 - podSelector:
51 matchLabels:
52 {{ template "common.names.fullname" . }}-client: "true"
53 {{- if .Values.networkPolicy.ingressNSMatchLabels }}
54 - namespaceSelector:
55 matchLabels:
56 {{- range $key, $value := .Values.networkPolicy.ingressNSMatchLabels }}
57 {{ $key | quote }}: {{ $value | quote }}
58 {{- end }}
59 {{- if .Values.networkPolicy.ingressNSPodMatchLabels }}
60 podSelector:
61 matchLabels:
62 {{- range $key, $value := .Values.networkPolicy.ingressNSPodMatchLabels }}
63 {{ $key | quote }}: {{ $value | quote }}
64 {{- end }}
65 {{- end }}
66 {{- end }}
67 {{- end }}
68 {{- if .Values.networkPolicy.extraIngress }}
69 {{- include "common.tplvalues.render" ( dict "value" .Values.networkPolicy.extraIngress "context" $ ) | nindent 4 }}
70 {{- end }}
71{{- end }}