{{- if .Values.networkPolicy.enabled }}
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: {{ include "who-need-help.fullname" . }}
  labels:
    {{- include "who-need-help.labels" . | nindent 4 }}
spec:
  podSelector:
    matchLabels:
      {{- include "who-need-help.selectorLabels" . | nindent 6 }}
  policyTypes:
    - Ingress
  ingress:
    # Web and worker nodes need unrestricted pod-to-pod Erlang distribution.
    - from:
        - podSelector:
            matchLabels:
              {{- include "who-need-help.selectorLabels" . | nindent 14 }}
    # Public web traffic, kubelet probes, and authenticated metrics use the
    # same fixed listener. All other inbound ports stay isolated.
    - ports:
        - protocol: TCP
          port: {{ .Values.app.port }}
{{- end }}
