{{- /*
Copyright Broadcom, Inc. All Rights Reserved.
SPDX-License-Identifier: APACHE-2.0
*/}}

apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ include "appsmith.redirect.fullname" . }}
  namespace: {{ include "common.names.namespace" . | quote }}
  labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
    app.kubernetes.io/component: backend
  {{- 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_main
      {{- /* This port is hardcoded because of Appsmith code */}}
      {{- /* https://github.com/appsmithorg/appsmith/blob/021b4177eac01a445cacf8bfb4688de449366701/app/server/appsmith-server/src/main/java/com/appsmith/server/configurations/CommonConfig.java#L136 */}}
      bind :8080
      default_backend be_main
    backend be_main
      server rts {{ include "appsmith.rts.fullname" .}}:{{ .Values.rts.service.ports.http }} check
