## mysql image version
## ref: https://hub.docker.com/r/library/mysql/tags/
##
global:
 imagePullSecrets:
   - osc-nexus-hub

mysqlImage: docker-hub.gitee.work/gitee-prod/mysql:5.7.32
xtraBackupImage: docker-hub.gitee.work/gitee-prod/xtrabackup:1.0

announceService:
  type: ClusterIP
  nodePort:
    main:
      mysql: 23306
      metrics: 29104
    backup:
      mysql: 33306
      metrics: 39104

securityContext:
  enabled: false
  fsGroup: 1001
  runAsUser: 1001

## Specify an imagePullPolicy (Required)
## It's recommended to change this to 'Always' if the image tag is 'latest'
## ref: http://kubernetes.io/docs/user-guide/images/#updating-images
##
imagePullPolicy: Always

## String to partially override orangehrm.fullname template (will maintain the release name)
##
nameOverride: "mysqlha"
## String to fully override orangehrm.fullname template
##
fullnameOverride: "gitee-mysql"

## Pod anti-affinity preset
## Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity
## Allowed values: soft, hard
podAntiAffinityPreset: soft
## Allowed values: soft, hard
nodeAffinityPreset:
  type: ""
  key: "kubernetes.io/node-type"
tolerations: []
  # - key: "middleware"
  #   operator: "Exists"
  #   effect: "NoSchedule"

mysqlha:
  ## Password for MySQL root user
  ##
  mysqlRootPassword: admin@2020
  ## Default: random 10 character string

  ## Username/password for MySQL replication user
  ##
  mysqlReplicationUser: replicaton
  mysqlReplicationPassword: admin@2020

  ## Create a database user
  ##
  #mysqlUser: gitee
  ## Default: random 10 character string
  #mysqlPassword: admin@2020


  ## Allow unauthenticated access, uncomment to enable
  ##
  # mysqlAllowEmptyPassword: true

  ## Create database with name and grant all permissions to user on startup, if needed
  # mysqlDatabase:

  ## Configuration files for the master and slaves
  ##
  master:
    replicaCount: 1
    configFiles:
      master.cnf: |
        # Apply this config only on the master.
        [mysqld]
        default-authentication-plugin=mysql_native_password
        log-slave-updates=on
        auto-increment-increment=2
        auto-increment-offset=1
        skip-name-resolve
        explicit-defaults-for-timestamp
        port=3306
        max-allowed-packet=1024M
        bind-address=0.0.0.0
        character-set-server=UTF8
        collation-server=utf8_general_ci
        sql-mode=NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
        max-connections=2000
        default-time-zone='+08:00'
        log-bin-trust-function-creators =TRUE
        sysdate-is-now                  =1
        #*************** gtid ***************
        gtid_mode                       =ON
        enforce_gtid_consistency        =ON
        master_verify_checksum          =ON
        sync_master_info                =1
        #************** binlog & relaylog ***************
        expire_logs_days                =7
        sync_binlog                     =1
        log-bin                         =mysql-bin
        log-bin-index                   =mysql-bin.index
        max_binlog_size                 =500M
        binlog_format                   =ROW
        binlog_rows_query_log_events    =ON
        binlog_cache_size               =128k
        binlog_stmt_cache_size          =128k
        max_binlog_cache_size           =2G
        max_binlog_stmt_cache_size      =2G
        relay_log                       =relay
        relay_log_index                 =relay.index
        max_relay_log_size              =500M
        relay_log_purge                 =ON
        relay_log_recovery              =ON
        #*************** muti thread slave ***************
        slave_parallel_type                         =LOGICAL_CLOCK
        slave_parallel_workers                      =4
        master_info_repository                      =TABLE
        relay_log_info_repository                   =TABLE
        #*********** innodb ***************
        default_storage_engine              =InnoDB
        default_tmp_storage_engine          =InnoDB
        internal_tmp_disk_storage_engine    =InnoDB
        innodb_file_per_table               =1
        innodb-flush-log-at-trx-commit      =2
        innodb_flush_method                 =O_DIRECT
        innodb_log_files_in_group           =2
        innodb-buffer-pool-size             =1024M
        #*************** rpl_semi_sync ***************
        plugin-load-add                             =rpl_semi_sync_master=semisync_master.so
        plugin-load-add                             =rpl_semi_sync_slave=semisync_slave.so
        rpl_semi_sync_master_enabled                =ON
        rpl_semi_sync_master_timeout                =1000
        rpl_semi_sync_master_trace_level            =32
        rpl_semi_sync_master_wait_for_slave_count   =1
        rpl_semi_sync_master_wait_no_slave          =ON
        rpl_semi_sync_master_wait_point             =AFTER_SYNC
        rpl_semi_sync_slave_enabled                 =ON
        rpl_semi_sync_slave_trace_level             =32

        [client]
        port=3306
        default-character-set=UTF8
      slave.cnf: |
        # Apply this config only on slaves.
        [mysqld]
        default_authentication_plugin=mysql_native_password
        super-read-only
        skip-name-resolve
        explicit_defaults_for_timestamp
        port=3306
        max_allowed_packet=1024M
        bind-address=0.0.0.0
        character-set-server=UTF8
        collation-server=utf8_general_ci
        sql_mode=NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
        default_storage_engine=InnoDB
        max_connections=512
        default-time-zone='+08:00'

        [client]
        port=3306
        default-character-set=UTF8
    ## Enable persistence using Persistent Volume Claims
    ## ref: http://kubernetes.io/docs/user-guide/persistent-volumes/
    ##

    resources:
      requests:
        cpu: 500m
        memory: 1Gi
      limits:
        cpu: "2"
        memory: 8Gi
    persistence:
      enabled: true
      ## If defined, storageClassName: <storageClass>
      ## If set to "-", storageClassName: "", which disables dynamic provisioning
      ## If undefined (the default) or set to null, no storageClassName spec is
      ##   set, choosing the default provisioner.  (gp2 on AWS, azure-disk on
      ##   Azure, standard on GKE, AWS & OpenStack)
      ##
      # storageClass: "-"
      accessModes:
      - ReadWriteOnce
      size: 10Gi
      annotations: {}

  backup:
    replicaCount: 1  
    configFiles:
      master.cnf: |
        # Apply this config only on the master.
        [mysqld]
        default-authentication-plugin=mysql_native_password
        log-slave-updates=on
        auto-increment-increment=2
        auto-increment-offset=2
        skip-name-resolve
        explicit-defaults-for-timestamp
        port=3306
        max-allowed-packet=1024M
        bind-address=0.0.0.0
        character-set-server=UTF8
        collation-server=utf8_general_ci
        sql-mode=NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
        max-connections=2000
        default-time-zone='+08:00'
        log-bin-trust-function-creators =TRUE
        sysdate-is-now                  =1
        #*************** gtid ***************
        gtid_mode                       =ON
        enforce_gtid_consistency        =ON
        master_verify_checksum          =ON
        sync_master_info                =1
        #************** binlog & relaylog ***************
        expire_logs_days                =7
        sync_binlog                     =1
        log-bin                         =mysql-bin
        log-bin-index                   =mysql-bin.index
        max_binlog_size                 =500M
        binlog_format                   =ROW
        binlog_rows_query_log_events    =ON
        binlog_cache_size               =128k
        binlog_stmt_cache_size          =128k
        max_binlog_cache_size           =2G
        max_binlog_stmt_cache_size      =2G
        relay_log                       =relay
        relay_log_index                 =relay.index
        max_relay_log_size              =500M
        relay_log_purge                 =ON
        relay_log_recovery              =ON
        #*************** muti thread slave ***************
        slave_parallel_type                         =LOGICAL_CLOCK
        slave_parallel_workers                      =4
        master_info_repository                      =TABLE
        relay_log_info_repository                   =TABLE
        #*********** innodb ***************
        default_storage_engine              =InnoDB
        default_tmp_storage_engine          =InnoDB
        internal_tmp_disk_storage_engine    =InnoDB
        innodb_file_per_table               =1
        innodb-flush-log-at-trx-commit      =2
        innodb_flush_method                 =O_DIRECT
        innodb_log_files_in_group           =2
        innodb-buffer-pool-size             = 1024M
        #*************** rpl_semi_sync ***************
        plugin-load-add                             =rpl_semi_sync_master=semisync_master.so
        plugin-load-add                             =rpl_semi_sync_slave=semisync_slave.so
        rpl_semi_sync_master_enabled                =ON
        rpl_semi_sync_master_timeout                =1000
        rpl_semi_sync_master_trace_level            =32
        rpl_semi_sync_master_wait_for_slave_count   =1
        rpl_semi_sync_master_wait_no_slave          =ON
        rpl_semi_sync_master_wait_point             =AFTER_SYNC
        rpl_semi_sync_slave_enabled                 =ON
        rpl_semi_sync_slave_trace_level             =32

        [client]
        port=3306
        default-character-set=UTF8
      slave.cnf: |
        # Apply this config only on slaves.
        [mysqld]
        default_authentication_plugin=mysql_native_password
        super-read-only
        skip-name-resolve
        explicit_defaults_for_timestamp
        port=3306
        max_allowed_packet=1024M
        bind-address=0.0.0.0
        character-set-server=UTF8
        collation-server=utf8_general_ci
        sql_mode=NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
        default_storage_engine=InnoDB
        max_connections=512
        default-time-zone='+08:00'

        [client]
        port=3306
        default-character-set=UTF8
    ## Enable persistence using Persistent Volume Claims
    ## ref: http://kubernetes.io/docs/user-guide/persistent-volumes/
    ##
    resources:
      requests:
        cpu: 500m
        memory: 1Gi
      limits:
        cpu: "2"
        memory: 8Gi
    persistence:
      enabled: true
      ## If defined, storageClassName: <storageClass>
      ## If set to "-", storageClassName: "", which disables dynamic provisioning
      ## If undefined (the default) or set to null, no storageClassName spec is
      ##   set, choosing the default provisioner.  (gp2 on AWS, azure-disk on
      ##   Azure, standard on GKE, AWS & OpenStack)
      ##
      # storageClass: "-"
      accessModes:
      - ReadWriteOnce
      size: 10Gi
      annotations: {}
  podAnnotations: {}
## Use an alternate scheduler, e.g. "stork".
## ref: https://kubernetes.io/docs/tasks/administer-cluster/configure-multiple-schedulers/
##
# schedulerName:



metrics:
  enabled: false
  image: prom/mysqld-exporter
  imageTag: v0.10.0
  annotations: {}

  livenessProbe:
    initialDelaySeconds: 15
    timeoutSeconds: 5
  readinessProbe:
    initialDelaySeconds: 5
    timeoutSeconds: 1
  resources:
    limits:
      cpu: 250m
      memory: 512Mi
    requests:
      cpu: 100m
      memory: 100Mi
  prometheusRule:
    enabled: false
    rules: []
  serviceMonitor:
    ## If the operator is installed in your cluster, set to true to create a Service Monitor Entry
    enabled: false

    ## Specify the namespace where Prometheus Operator is running
    ##
    # namespace: monitoring

    ## Specify the interval at which metrics should be scraped
    ##
    interval: 30s
    ## Specify the timeout after which the scrape is ended
    ##
    # scrapeTimeout: 30s
    ## Used to pass Labels that are used by the Prometheus installed in your cluster to select Service Monitors to work with
    ## ref: https://github.com/coreos/prometheus-operator/blob/master/Documentation/api.md#prometheusspec
    ##
    additionalLabels: {}
