{{- if .Values.networkPolicy.enabled }} kind: NetworkPolicy apiVersion: {{ include "common.capabilities.networkPolicy.apiVersion" . }} metadata: name: {{ printf "%s-controller" (include "common.names.fullname" .) }} namespace: {{ include "common.names.namespace" . | quote }} labels: {{- include "common.labels.standard" . | nindent 4 }} app.kubernetes.io/component: controller {{- if .Values.commonLabels }} {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }} {{- end }} {{- if .Values.commonAnnotations }} annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }} {{- end }} spec: podSelector: matchLabels: {{- include "common.labels.matchLabels" . | nindent 6 }} app.kubernetes.io/component: controller policyTypes: - Ingress ingress: # Allow prometheus scrapes for metrics - ports: - port: {{ .Values.controller.containerPorts.metrics }} protocol: TCP {{- if .Values.networkPolicy.ingressNSMatchLabels }} from: - namespaceSelector: matchLabels: {{- range $key, $value := .Values.networkPolicy.ingressNSMatchLabels }} {{ $key | quote }}: {{ $value | quote }} {{- end }} {{- if .Values.networkPolicy.ingressNSPodMatchLabels }} podSelector: matchLabels: {{- range $key, $value := .Values.networkPolicy.ingressNSPodMatchLabels }} {{ $key | quote }}: {{ $value | quote }} {{- end }} {{- end }} {{- end }} {{- end }}