apiVersion: v1
kind: ConfigMap
metadata:
  name: milvus-mysql-configmap
  namespace: milvus
data:
    milvus_mysql_config.yml: |
      [mysqld]
      pid-file        = /var/run/mysqld/mysqld.pid
      socket          = /var/run/mysqld/mysqld.sock
      datadir         = /data
      log-error       = /var/log/mysql/error.log # mount out to host
      # By default we only accept connections from localhost
      bind-address   = 0.0.0.0
      # Disabling symbolic-links is recommended to prevent assorted security risks
      symbolic-links=0
      character-set-server = utf8mb4
      collation-server = utf8mb4_unicode_ci
      init_connect='SET NAMES utf8mb4'
      skip-character-set-client-handshake = true
      max_connections = 1000
      wait_timeout = 31536000

---

apiVersion: v1
kind: ConfigMap
metadata:
  name: milvus-proxy-configmap
  namespace: milvus
data:
    milvus_proxy_config.yml: |
      DEBUG=True
      TESTING=False

      WOSERVER=tcp://milvus-wo-servers:19530
      SERVER_PORT=19530

      DISCOVERY_CLASS_NAME=kubernetes
      DISCOVERY_KUBERNETES_NAMESPACE=milvus
      DISCOVERY_KUBERNETES_POD_PATT=.*-ro-servers-.*
      DISCOVERY_KUBERNETES_LABEL_SELECTOR=tier=ro-servers
      DISCOVERY_KUBERNETES_POLL_INTERVAL=10
      DISCOVERY_KUBERNETES_IN_CLUSTER=True

      SQLALCHEMY_DATABASE_URI=mysql+pymysql://root:milvusroot@milvus-mysql:3306/milvus?charset=utf8mb4
      SQLALCHEMY_POOL_SIZE=50
      SQLALCHEMY_POOL_RECYCLE=7200

      LOG_PATH=/var/log/milvus
      TIMEZONE=Asia/Shanghai
---

apiVersion: v1
kind: ConfigMap
metadata:
  name: milvus-roserver-configmap
  namespace: milvus
data:
  config.yml: |
    server_config:
      address: 0.0.0.0
      port: 19530
      mode: cluster_readonly

    db_config:
      primary_path: /var/milvus
      backend_url: mysql://root:milvusroot@milvus-mysql:3306/milvus
      insert_buffer_size: 2

    metric_config:
      enable_monitor: off # true is on, false is off

    cache_config:
        cpu_cache_capacity: 12   # memory pool to hold index data, unit: GB
        cpu_cache_free_percent: 0.85
        insert_cache_immediately: false
        # gpu_cache_capacity: 4
        # gpu_cache_free_percent: 0.85
        # gpu_ids:
          # - 0

    engine_config:
        use_blas_threshold: 800

    resource_config:
        search_resources:
            - gpu0

  log.conf: |
    * GLOBAL:
        FORMAT                  =   "%datetime | %level | %logger | %msg"
        FILENAME                =   "/var/milvus/logs/milvus-ro-%datetime{%H:%m}-global.log"
        ENABLED                 =   true
        TO_FILE                 =   true
        TO_STANDARD_OUTPUT      =   true
        SUBSECOND_PRECISION     =   3
        PERFORMANCE_TRACKING    =   false
        MAX_LOG_FILE_SIZE       =   2097152 ## Throw log files away after 2MB
    * DEBUG:
        FILENAME                =   "/var/milvus/logs/milvus-ro-%datetime{%H:%m}-debug.log"
        ENABLED                 =   true
    * WARNING:
        FILENAME                =   "/var/milvus/logs/milvus-ro-%datetime{%H:%m}-warning.log"
    * TRACE:
        FILENAME                =   "/var/milvus/logs/milvus-ro-%datetime{%H:%m}-trace.log"
    * VERBOSE:
        FORMAT                  =   "%datetime{%d/%M/%y} | %level-%vlevel | %msg"
        TO_FILE                 =   true
        TO_STANDARD_OUTPUT      =   true
    ## Error logs
    * ERROR:
        ENABLED                 =   true
        FILENAME                =   "/var/milvus/logs/milvus-ro-%datetime{%H:%m}-error.log"
    * FATAL:
        ENABLED                 =   true
        FILENAME                =   "/var/milvus/logs/milvus-ro-%datetime{%H:%m}-fatal.log"

---

apiVersion: v1
kind: ConfigMap
metadata:
  name: milvus-woserver-configmap
  namespace: milvus
data:
  config.yml: |
    server_config:
      address: 0.0.0.0
      port: 19530
      mode: cluster_writable

    db_config:
      primary_path: /var/milvus
      backend_url: mysql://root:milvusroot@milvus-mysql:3306/milvus
      insert_buffer_size: 2

    metric_config:
      enable_monitor: off # true is on, false is off

    cache_config:
        cpu_cache_capacity: 2   # memory pool to hold index data, unit: GB
        cpu_cache_free_percent: 0.85
        insert_cache_immediately: false
        # gpu_cache_capacity: 4
        # gpu_cache_free_percent: 0.85
        # gpu_ids:
          # - 0

    engine_config:
        use_blas_threshold: 800

    resource_config:
        search_resources:
            - gpu0


  log.conf: |
    * GLOBAL:
        FORMAT                  =   "%datetime | %level | %logger | %msg"
        FILENAME                =   "/var/milvus/logs/milvus-wo-%datetime{%H:%m}-global.log"
        ENABLED                 =   true
        TO_FILE                 =   true
        TO_STANDARD_OUTPUT      =   true
        SUBSECOND_PRECISION     =   3
        PERFORMANCE_TRACKING    =   false
        MAX_LOG_FILE_SIZE       =   2097152 ## Throw log files away after 2MB
    * DEBUG:
        FILENAME                =   "/var/milvus/logs/milvus-wo-%datetime{%H:%m}-debug.log"
        ENABLED                 =   true
    * WARNING:
        FILENAME                =   "/var/milvus/logs/milvus-wo-%datetime{%H:%m}-warning.log"
    * TRACE:
        FILENAME                =   "/var/milvus/logs/milvus-wo-%datetime{%H:%m}-trace.log"
    * VERBOSE:
        FORMAT                  =   "%datetime{%d/%M/%y} | %level-%vlevel | %msg"
        TO_FILE                 =   true
        TO_STANDARD_OUTPUT      =   true
    ## Error logs
    * ERROR:
        ENABLED                 =   true
        FILENAME                =   "/var/milvus/logs/milvus-wo-%datetime{%H:%m}-error.log"
    * FATAL:
        ENABLED                 =   true
        FILENAME                =   "/var/milvus/logs/milvus-wo-%datetime{%H:%m}-fatal.log"
