apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ template "fullname" . }}
  labels:
    app: {{ template "fullname" . }}
    chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
    release: "{{ .Release.Name }}"
    heritage: "{{ .Release.Service }}"
data:
{{ toYaml .Values.mysqlha.configFiles | indent 2 }}
  server-id.cnf: |
    [mysqld]
    server-id=@@SERVER_ID@@
  create-replication-user.sh: |-
    #!/bin/bash
    set -e

    mysql -h 127.0.0.1 --verbose -e "CREATE USER IF NOT EXISTS '${MYSQL_REPLICATION_USER}' IDENTIFIED BY '${MYSQL_REPLICATION_PASSWORD}';"
    mysql -h 127.0.0.1 --verbose -e "GRANT PROCESS, RELOAD, REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO '${MYSQL_REPLICATION_USER}';"
    mysql -h 127.0.0.1 --verbose -e "FLUSH PRIVILEGES;"
