{{- if .Values.networkPolicies.enabled }}
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: longhorn-manager
  namespace: longhorn-system
spec:
  podSelector:
    matchLabels:
      app: longhorn-manager
  policyTypes:
  - Ingress
  ingress:
  - from:
    - podSelector:
        matchLabels:
          app: longhorn-manager
    - podSelector:
        matchLabels:
          app: longhorn-ui
    - podSelector:
        matchLabels:
          app: longhorn-csi-plugin
    - podSelector:
        matchLabels:
          longhorn.io/managed-by: longhorn-manager
        matchExpressions:
          - { key: recurring-job.longhorn.io, operator: Exists }
    - podSelector:
        matchExpressions:
          - { key: longhorn.io/job-task, operator: Exists }
    - podSelector:
        matchLabels:
          app: longhorn-driver-deployer
{{- end }}
