{{- if .Values.networkPolicy.enabled }}
kind: NetworkPolicy
apiVersion: networking.k8s.io/v1
metadata:
  name: {{ include "minio.fullname" . }}
  namespace: {{ .Release.Namespace }}
  labels: {{- include "minio.labels" . | nindent 4 }}
spec:
  podSelector:
    matchLabels:
      app.kubernetes.io/name: {{ include "minio.name" . }}
      app.kubernetes.io/instance: {{ .Release.Name }}
  ingress:
    # Allow inbound connections
    - ports:
        - port: 9000
      {{- if not .Values.networkPolicy.allowExternal }}
      from:
        - podSelector:
            matchLabels:
              {{ include "minio.fullname" . }}-client: "true"
      {{- end }}
{{- end }}
