{{- if .Values.enabled.clusterMode }}
{{- $namespace := .Release.Namespace -}}
{{- $applicationName := .Values.appName.clusterMode -}}
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ $applicationName }}-env
  namespace: {{ $namespace }}
  labels:
    {{- include "uavcloud-middleware.emqx.labels.standard" . | nindent 4 }}
data:
  EMQX_CLUSTER__K8S__ADDRESS_TYPE: hostname
  EMQX_CLUSTER__K8S__APISERVER: https://kubernetes.default.svc:443
  EMQX_CLUSTER__K8S__SUFFIX: svc.cluster.local
  EMQX_NAME: {{ $applicationName }}
  EMQX_CLUSTER__K8S__APP_NAME: {{ $applicationName }}
  EMQX_CLUSTER__DISCOVERY: k8s
  EMQX_CLUSTER__K8S__SERVICE_NAME: {{ $applicationName }}-headless
  EMQX_CLUSTER__K8S__NAMESPACE: {{ $namespace }}
  EMQX_ALLOW_ANONYMOUS: "false"
  EMQX_ACL_NOMATCH: "deny"
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ $applicationName }}-cm
  namespace: {{ $namespace }}
  labels:
    {{- include "uavcloud-middleware.emqx.labels.standard" . | nindent 4 }}
data:
  emqx_auth_username.conf: |-
    {{- include "uavcloud-middleware.emqx.cluster.config.emqx_auth_username" . | nindent 4 }}

  acl.conf: |-
    {{- include "uavcloud-middleware.emqx.cluster.config.acl" . | nindent 4 }}

  loaded_plugins: |-
    {{- include "uavcloud-middleware.emqx.cluster.config.loaded_plugins" . | nindent 4 }}
---
{{- end }}
