apiVersion: v1
kind: ConfigMap
metadata:
  name: mysql-config
  namespace: default
data:
  galera.cnf: |
    [galera]
    user = mysql
    bind-address = 0.0.0.0
    default_storage_engine = InnoDB
    binlog_format = ROW
    innodb_autoinc_lock_mode = 2
    innodb_flush_log_at_trx_commit = 0
    query_cache_size = 0
    query_cache_type = 0
    socket = /run/mysqld/mysqld.sock
    wsrep_on=ON
    wsrep_provider=/usr/lib/galera/libgalera_smm.so
    wsrep_sst_method=rsync
    # Cluster settings (automatically sets)
    #wsrep_cluster_address=gcomm://  # set from DNS like galera.default.svc.local (see detail: https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/)
    #wsrep_cluster_name=galera       # set service name from environment
    #wsrep_node_address=127.0.0.1    # set pod IP from environment
  mariadb.cnf: |
    [client]
    default-character-set = utf8mb4
    socket = /run/mysqld/mysqld.sock
    [mysqld]
    character-set-server  = utf8mb4
    collation-server      = utf8mb4_general_ci
    socket = /run/mysqld/mysqld.sock
  tune.cnf: |
    [mysqld]
    #
    # * Fine Tuning
    #
    max_connections         = 600
    connect_timeout         = 5
    wait_timeout            = 600
    max_allowed_packet      = 16M
    thread_cache_size       = 128
    sort_buffer_size        = 4M
    bulk_insert_buffer_size = 16M
    tmp_table_size          = 32M
    max_heap_table_size     = 32M
    #
    # * Query Cache Configuration
    #
    # Cache only tiny result sets, so we can fit more in the query cache.
    query_cache_limit               = 128K
    query_cache_size                = 64M
    # for more write intensive setups, set to DEMAND or OFF
    #query_cache_type               = DEMAND
    #
    # * Logging and Replication
    #
    # Both location gets rotated by the cronjob.
    # Be aware that this log type is a performance killer.
    # As of 5.1 you can enable the log at runtime!
    #general_log_file        = /var/log/mysql/mysql.log
    #general_log             = 1
    #
    # Error logging goes to syslog due to /etc/mysql/conf.d/mysqld_safe_syslog.cnf.
    #
    # we do want to know about network errors and such
    #log_warnings           = 2
    #
    # Enable the slow query log to see queries with especially long duration
    #slow_query_log[={0|1}]
    slow_query_log_file     = /var/log/mysql/mariadb-slow.log
    long_query_time = 10
    #log_slow_rate_limit    = 1000
    #log_slow_verbosity     = query_plan

    #log-queries-not-using-indexes
    #log_slow_admin_statements
    #
    # * InnoDB
    #
    # InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
    # Read the manual for more InnoDB related options. There are many!
    default_storage_engine  = InnoDB
    # you can't just change log file size, requires special procedure
    innodb_log_file_size    = 64M
    innodb_buffer_pool_size = 939524096
    innodb_log_buffer_size  = 8M
    innodb_file_per_table   = 1
    innodb_open_files       = 400
    innodb_io_capacity      = 400
    innodb_flush_method     = O_DIRECT
