{{- if .Values.metrics.enabled }}
apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ printf "%s-haproxy-conf" (include "common.names.fullname" .) }}
  namespace: {{ .Release.Namespace | quote }}
  labels: {{- include "common.labels.standard" . | nindent 4 }}
    app.kubernetes.io/component: metrics
    {{- if .Values.commonLabels }}
    {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
    {{- end }}
  {{- if .Values.commonAnnotations }}
  annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
  {{- end }}
data:
  haproxy.cfg: |
    global
      log stdout format raw local0
      maxconn 1024
    defaults
      log global
      timeout client 60s
      timeout connect 60s
      timeout server 60s
    frontend fe_metrics
      bind :{{ .Values.metrics.containerPort }}
      default_backend be_metrics
    backend be_metrics
      server micrometer localhost:{{ .Values.locator.containerPorts.metrics }} check
{{- end }}
