apiVersion: service.aep.asag.io/v1
kind: Definition
metadata:
  namespace: asag
  name: mysql-0.0.0-38d75c00
spec:
  name: mysql
  version: 0.0.0-38d75c00
  includes:
    - vendor: asag
      name: defaults-service
      version: 0.2.8
  clusters:
    - name: mysql
      flags:
        - key: v1_role
          from: value
          value: mysql
          to: label
        - key: delay_final_config
          from: value
          value: true
          to: annotation
      settings:
        - name: disable_backup
          from:
            - user
          schema:
            type: string
            description: Data backup on the master node is disabled by default for
              performance reasons, but the user should be able to override this setting
              in case they want to deploy a single-node MySQL service where data backup
              can't be delegated to a slave node.
            default: 'true'
      sizing:
        initial: 3
        minimum: 1
        maximum: 10
        increment: 1
        specific:
          initial:
            - flags:
                - key: v1_is_master
                  from: value
                  to: label
                  value: 'true'
                - key: v1_dbmaster
                  from: value
                  to: label
                  value: 'true'
                - key: v1_disable_backup
                  from: setting
                  to: label
                  setting: disable_backup
            - flags:
                - key: v1_is_master
                  from: value
                  value: false
                - key: v1_disable_backup
                  from: value
                  to: label
                  value: 'false'
          additional:
            flags:
              - key: v1_is_master
                from: value
                to: label
                value: 'false'
              - key: v1_dbmaster
                from: value
                to: label
                value: 'false'
              - key: v1_disable_backup
                from: value
                to: label
                value: 'true'
      topologyqueries:
        - name: master
          format: array
          scope: cluster
          flags:
            - key: v1_is_master
              value: 'true'
        - name: slaves
          format: array
          scope: cluster
          flags:
            - key: v1_is_master
              value: 'false'
      podspec:
        containers:
          - name: mysql
            image: aep/base_jammy
      provides:
        - name: mysql-rw
          network: loadbalanced
          exposed: true
          servicespec:
            ports:
              - name: mysql
                protocol: TCP
                port: 3306
                targetPort: 3306
          filter:
            - key: v1_is_master
              value: 'true'
        - name: mysql-ro
          network: loadbalanced
          exposed: true
          servicespec:
            ports:
              - name: mysql
                protocol: TCP
                port: 3306
                targetPort: 3306
          filter:
            - key: v1_is_master
              value: 'false'
  dependencies:
    operator:
      name: mysql-operator
      vendor: asag
      version: 0.0.0-38d75c00
  settings:
    - name: environment
      schema:
        default: mysql_prod
