apiVersion: v1
kind: Service
metadata:
  name: {{ template "kube-state-metrics.fullname" . }}
  labels:
    app: {{ template "kube-state-metrics.name" . }}
    chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
    release: "{{ .Release.Name }}"
    heritage: "{{ .Release.Service }}"
  {{- if .Values.prometheusScrape }}
  annotations:
    prometheus.io/scrape: '{{ .Values.prometheusScrape }}'
  {{- end }}
spec:
  type: "{{ .Values.service.type }}"
  ports:
  - name: "http"
    protocol: TCP
    port: {{ .Values.service.port }}
  {{- if .Values.service.nodePort }}
    nodePort: {{ .Values.service.nodePort }}
  {{- end }}
    targetPort: 8080
{{- if .Values.service.loadBalancerIP }}
  loadBalancerIP: "{{ .Values.service.loadBalancerIP }}"
{{- end }}
  selector:
    app: {{ template "kube-state-metrics.name" . }}
    release: {{ .Release.Name }}
