apiVersion: service.aep.asag.io/v1
kind: Definition
metadata:
  name: psql-0.1.2
  namespace: asag
spec:
  clusters:
    - flags:
        - from: value
          key: v1_role
          to: label
          value: postgres
      name: psql
      podspec:
        containers:
          - image: aep/base_jammy
            name: psql
      provides:
        - exposed: true
          filter:
            - key: v1_is_master
              value: "true"
          name: psql-rw
          network: loadbalanced
          servicespec:
            ports:
              - name: postgresql
                port: 5432
                protocol: TCP
                targetPort: 5432
        - exposed: true
          filter:
            - key: v1_is_master
              value: "false"
          name: psql-ro
          network: loadbalanced
          servicespec:
            ports:
              - name: postgresql
                port: 5432
                protocol: TCP
                targetPort: 5432
      settings:
        - from:
            - user
          name: disable_backup
          schema:
            default: "true"
            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 PostgreSQL service where data backup can't be delegated to a slave node.
            type: string
      sizing:
        increment: 1
        initial: 3
        maximum: 10
        minimum: 1
        specific:
          additional:
            flags:
              - from: value
                key: v1_is_master
                to: label
                value: "false"
              - from: value
                key: v1_disable_backup
                to: label
                value: "true"
          initial:
            - flags:
                - from: value
                  key: v1_is_master
                  to: label
                  value: "true"
                - from: setting
                  key: v1_disable_backup
                  setting: disable_backup
                  to: label
            - flags:
                - from: value
                  key: v1_is_master
                  to: label
                  value: "false"
                - from: value
                  key: v1_disable_backup
                  to: label
                  value: "false"
      topologyqueries:
        - flags:
            - key: v1_is_master
              value: "true"
          format: array
          name: master
          scope: cluster
        - flags:
            - key: v1_is_master
              value: "false"
          format: array
          name: slaves
          scope: cluster
  dependencies:
    operator:
      name: psql-operator
      vendor: asag
      version: 0.1.2
  includes:
    - name: defaults-service
      vendor: asag
      version: 0.2.9
  name: psql
  settings:
    - name: environment
      schema:
        default: psql_prod
  version: 0.1.2
