# argocd_source_networkpolicy.yaml
{{- if .Values.networkPolicy.enabled }}
kind: NetworkPolicy
apiVersion: {{ template "networkPolicy.apiVersion" . }}
metadata:
  name: "{{ template "redis.fullname" . }}"
  labels:
    app: {{ template "redis.name" . }}
    chart: {{ template "redis.chart" . }}
    release: "{{ .Release.Name }}"
    heritage: "{{ .Release.Service }}"
spec:
  podSelector:
    matchLabels:
      app: {{ template "redis.name" . }}
  ingress:
    # Allow inbound connections
    - ports:
      - port: 6379
      {{- if not .Values.networkPolicy.allowExternal }}
      from:
        - podSelector:
            matchLabels:
              {{ template "redis.fullname" . }}-client: "true"
      {{- end }}
    {{- if .Values.metrics.enabled }}
    # Allow prometheus scrapes for metrics
    - ports:
      - port: 9121
    {{- end }}
{{- end }}