{{- if and .Values.networkPolicy.enabled .Values.metrics.enabled }} apiVersion: networking.k8s.io/v1 kind: NetworkPolicy metadata: labels: app.kubernetes.io/managed-by: {{ .Release.Service }} app.kubernetes.io/name: {{ include "terdut-operator.name" . }} name: {{ include "terdut-operator.resourceName" (dict "suffix" "allow-metrics-traffic" "context" $) }} namespace: {{ .Release.Namespace }} spec: podSelector: matchLabels: control-plane: controller-manager app.kubernetes.io/name: {{ include "terdut-operator.name" . }} policyTypes: - Ingress ingress: - from: - namespaceSelector: matchLabels: metrics: enabled ports: - port: {{ .Values.metrics.port }} protocol: TCP {{- end }}