apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ kolla_kubernetes.template.vars.configmap_name }}
  namespace: {{ kolla_kubernetes_namespace }}
data:
  haproxy.cfg: |
    global
      chroot /var/lib/haproxy
      user haproxy
      group haproxy
      daemon
      log /var/lib/kolla/heka/log local0
      maxconn 4000
      # commented out for now. Doesn't work on haproxy from kolla 2.x
      # its unused anyway.
      #stats socket /var/lib/kolla/haproxy/haproxy.sock

    defaults
      log global
      mode http
      option redispatch
      option httplog
      option forwardfor
      retries 3
      timeout http-request 10s
      timeout queue 1m
      timeout connect 10s
      timeout client 1m
      timeout server 1m
      timeout check 10s

    listen api
      bind 0.0.0.0:{{ global[kolla_kubernetes.template.vars.port_name] }}
      server local-api 127.0.0.1:8080 check inter 2000 rise 2 fall 5

{% if kolla_kubernetes.template.vars.configmap_name == 'nova-api-haproxy' %}
    listen metadata
      bind 0.0.0.0:{{ nova_metadata_port }}
      server local-meta 127.0.0.1:8081 check inter 2000 rise 2 fall 5
{% endif %}

  config.json: |
    {
        "command": "/usr/sbin/haproxy-systemd-wrapper -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid",
        "config_files": [{
            "source": "{{ container_config_directory }}/haproxy.cfg",
            "dest": "/etc/haproxy/haproxy.cfg",
            "owner": "root",
            "perm": "0644"
        }]
    }
