{{- if .Values.networkPolicy.enabled }}
apiVersion: {{ template "prometheus.networkPolicy.apiVersion" . }}
kind: NetworkPolicy
metadata:
  name: {{ template "prometheus.kubeStateMetrics.fullname" . }}
  labels:
    app: {{ template "prometheus.name" . }}
    chart: {{ .Chart.Name }}-{{ .Chart.Version }}
    component: "{{ .Values.kubeStateMetrics.name }}"
    heritage: {{ .Release.Service }}
    release: {{ .Release.Name }}
spec:
  podSelector:
    matchLabels:
      app: {{ template "prometheus.name" . }}
      component: "{{ .Values.kubeStateMetrics.name }}"
      release: {{ .Release.Name }}
  ingress:
  - from:
    - podSelector:
        matchLabels:
          release: {{ .Release.Name }}
          component: "{{ .Values.server.name }}"
  - ports:
    - port: 8080
{{- end }}
