# helm_charts_controller-stats-service.yaml
{{- if .Values.controller.stats.enabled }}
apiVersion: v1
kind: Service
metadata:
{{- if .Values.controller.stats.service.annotations }}
  annotations:
{{ toYaml .Values.controller.stats.service.annotations | indent 4 }}
{{- end }}
  labels:
    app: {{ template "haproxy-ingress.labels.app.controller" . }}
    chart: {{ .Chart.Name }}-{{ .Chart.Version }}
    component: "{{ .Values.controller.name }}"
    heritage: {{ .Release.Service }}
    release: {{ .Release.Name }}
  name: {{ template "haproxy-ingress.controller.fullname" . }}-stats
  namespace: {{ .Release.Namespace }}
spec:
{{- if .Values.controller.stats.service.clusterIP }}
  clusterIP: "{{ .Values.controller.stats.service.clusterIP }}"
{{- end }}
{{- if .Values.controller.stats.service.externalIPs }}
  externalIPs:
{{ toYaml .Values.controller.stats.service.externalIPs | indent 4 }}
{{- end }}
{{- if .Values.controller.stats.service.loadBalancerIP }}
  loadBalancerIP: "{{ .Values.controller.stats.service.loadBalancerIP }}"
{{- end }}
{{- if .Values.controller.stats.service.loadBalancerSourceRanges }}
  loadBalancerSourceRanges:
{{ toYaml .Values.controller.stats.service.loadBalancerSourceRanges | indent 4 }}
{{- end }}
  ports:
    - name: stats
      port: {{ .Values.controller.stats.service.servicePort }}
      targetPort: stats
  selector:
    app: {{ template "haproxy-ingress.labels.app.controller" . }}
    component: "{{ .Values.controller.name }}"
    release: {{ .Release.Name }}
  type: "{{ .Values.controller.stats.service.type }}"
{{- end }}