apiVersion: v1
kind: ConfigMap
metadata:
  name: kube-apiserver-load-balancer
data:
  haproxy.cfg: |
    defaults
      # Do TLS passthrough.
      mode tcp
      # Required values for both frontend and backend.
      timeout connect 5s
      timeout client 30s
      timeout client-fin 30s
      timeout server 30s
      timeout tunnel 21d

    frontend kube-apiserver
      bind 0.0.0.0:6443
      default_backend kube-apiserver

    backend kube-apiserver
      option httpchk
      http-check send meth GET uri /healthz ver HTTP/1.1 hdr host kube-apiserver
      {{- range $index, $server := .Values.apiServers }}
      server {{ $index }} {{ $server }} verify none check check-ssl
      {{- end }}

    frontend stats
      bind 0.0.0.0:8080
      mode http
      http-request use-service prometheus-exporter if { path /metrics }
      stats enable
      stats uri /metrics
      stats refresh 10s
