{{- if .Values.networkPolicy.enabled }}
apiVersion: "networking.k8s.io/v1"
kind: "NetworkPolicy"
metadata:
  name: {{ include "fluent-bit.fullname" . | quote }}
  namespace: {{ .Release.Namespace }}
  labels:
    {{- include "fluent-bit.labels" . | nindent 4 }}
spec:
  policyTypes:
    - "Ingress"
  podSelector:
    matchLabels:
      {{- include "fluent-bit.selectorLabels" . | nindent 6 }}
  ingress:
    {{- with .Values.networkPolicy.ingress }}
    - from:
        {{- with .from }}{{- . | toYaml | nindent 8 }}{{- else }} []{{- end }}
      ports:
        - protocol: "TCP"
          port: {{ $.Values.service.port }}
    {{- end }}
{{- end }}
