apiVersion: v1
kind: ConfigMap
metadata:
  name: galeraconf
  namespace: galera
data:
  my.cnf: |
    [mysqld]

    user=mysql
    max_connections = 400
    max_user_connections=200

    bind-address=0.0.0.0

    # Connection and Thread variables

    #port                           = 3306
    #socket                         = /var/run/mysqld/mysql.sock          # Use mysqld.sock on Ubuntu, conflicts with AppArmor otherwise
    datadir                         = /var/lib/mysql

    # InnoDB variables

    #innodb_strict_mode             = ON
    #innodb_file_format_check       = 1
    #innodb_file_format             = Barracuda                           # For dynamic and compressed InnoDB tables
    innodb_buffer_pool_size         = 128M                                # Go up to 80% of your available RAM
    #innodb_buffer_pool_instances   = 8                                   # Bigger if huge InnoDB Buffer Pool or high concurrency


    # Galera specific MySQL parameter

    default_storage_engine         = InnoDB                            # Galera only works with InnoDB
    innodb_flush_log_at_trx_commit = 0                                 # Durability is achieved by committing to the Group
    innodb_autoinc_lock_mode       = 2                                 # For parallel applying
    innodb_doublewrite             = 1						           # (the default) when using Galera provider of version >= 2.0.
    binlog_format                  = row                               # Galera only works with RBR
    #query_cache_type               = 0                                 # Use QC with Galera only in a Master/Slave set-up
    #query_cache_size               = 0									# only for versions prior to 5.5.40-galera, 10.0.14-galera and 10.1.2

    # WSREP parameter

    wsrep_on                       = on                                  # Only MariaDB >= 10.1
    wsrep_provider                 = /usr/lib/libgalera_smm.so    		# Location of Galera Plugin on Ubuntu
    # wsrep_provider                 = /usr/lib64/galera-3/libgalera_smm.so   # Location of Galera Plugin on CentOS 7
    wsrep_provider_options         = "gcache.size=300M; gcache.page_size=300M"                 # Depends on you workload, WS kept for IST

    wsrep_cluster_name             = "Cluster Name"          		     # Same Cluster name for all nodes
    wsrep_cluster_address          = "gcomm://192.168.0.2,192.168.0.3"   # The addresses of cluster nodes to connect to when starting up

    wsrep_node_name                = "Node A"                            # Unique node name
    wsrep_node_address             = 192.168.0.1                         # Our address where replication is done
    # wsrep_node_incoming_address    = 10.0.0.1                            # Our external interface where application comes from
    # wsrep_sync_wait                = 1                                   # If you need realy full-synchronous replication (Galera 3.6 and newer)
    # wsrep_slave_threads            = 16                                  # 4 - 8 per core, not more than wsrep_cert_deps_distance

    wsrep_sst_method               = mariabackup                         # SST method (initial full sync): mysqldump, rsync, rsync_wan, xtrabackup-v2
    wsrep_sst_auth                 = "sst:secret"                        # Username/password for sst user
    # wsrep_sst_receive_address      = 192.168.0.1                         # Our address where to receive SST

    #[xtrabackup]
    #user=sst2
    #password=$SST_PASSWORD

    [mysql_safe]
    log-error=/var/log/mysqld.log
    pid-file=/var/run/mysqld/mysqld.pid