kind: KafkaMirrorMaker2
apiVersion: eventstreams.ibm.com/v1beta2
metadata:
  name: mm2-backup
  namespace: europe
spec:

  # where to run Mirror Maker
  connectCluster: europe


  ##################################################
  # SPECIFY THE MIRRORS TO RUN
  ##################################################
  mirrors:
    #-----------------------------------------
    # North America -> Europe
    #-----------------------------------------
    - sourceCluster: northamerica
      targetCluster: europe
      #
      # mirror the messages on the "Loosehanger" topics ("LH")
      #
      topicsPattern: LH.*
      sourceConnector:
        config:
          # check for new topics every 10 minutes as we're not expecting new
          #  topics to be created regularly
          refresh.topics.interval.seconds: 600000
          refresh.topics.enabled: true

          # replication factor to use for created topics
          replication.factor: 3

          # match the names of topics in the target cluster to the
          #  name of the topics in the source cluster
          replication.policy.class: org.apache.kafka.connect.mirror.IdentityReplicationPolicy

          # use the target cluster to store the offset mapping information
          offset-syncs.topic.location: target
          # config for offset-syncs topic
          offset-syncs.topic.replication.factor: 3
          # max offset lag before sync'ing offset mapping
          offset.lag.max: 25

          # don't try to mirror the ACL's, as we will use the
          #  User Operator for this
          sync.topic.acls.enabled: false

          # sync config changes to topics in the source cluster to the
          #  target cluster every 10 minutes
          sync.topic.configs.enabled: true
          sync.topic.configs.interval.seconds: 600
      #
      # mirror consumer group offsets
      #
      # pattern for names of consumer groups to sync
      groupsPattern: consumer-.*
      checkpointConnector:
        config:
          # sync consumer offsets to the target cluster's __consumer_offsets topic
          emit.checkpoints.enabled : true
          sync.group.offsets.enabled: true

          # sync consumer offsets every minute
          emit.checkpoints.interval.seconds: 60
          sync.group.offsets.interval.seconds: 60

          # check for new consumer groups that match the pattern every 10 minutes
          refresh.groups.enabled: true
          refresh.groups.interval.seconds: 600

          # match the names of topics in the target cluster to the
          #  name of the topics in the source cluster
          replication.policy.class: org.apache.kafka.connect.mirror.IdentityReplicationPolicy

          # use the target cluster for offset mapping information
          offset-syncs.topic.location: target

          # config for checkpoints topic
          checkpoints.topic.replication.factor: 3
      #
      # check that backup is functional by sending periodic heartbeats
      #
      heartbeatConnector:
        config:
          # to know if the backup is running, Mirror Maker will send a
          #  heartbeat message once a minute to the target cluster
          emit.heartbeats.enabled: true
          emit.heartbeats.interval.seconds: 60

          # config for heartbeats topic
          heartbeats.topic.replication.factor: 3


  ##################################################
  # DEFINE THE KAFKA CLUSTERS TO USE FOR MIRRORING
  ##################################################
  clusters:
    #-----------------------------------------
    # North American region
    #-----------------------------------------
    - alias: northamerica
      bootstrapServers: na-eventstreams-kafka-bootstrap.north-america.svc:9098
      authentication:
        username: mm2-northamerica-backup
        passwordSecret:
          password: password
          secretName: mm2-northamerica-backup
        type: scram-sha-512
      tls:
        trustedCertificates:
          - certificate: ca.crt
            secretName: na-eventstreams-cluster-ca-cert
    #-----------------------------------------
    # European region
    #-----------------------------------------
    - alias: europe
      bootstrapServers: eu-eventstreams-kafka-bootstrap.europe.svc:9098
      authentication:
        username: mm2-europe-backup
        passwordSecret:
          password: password
          secretName: mm2-europe-backup
        type: scram-sha-512
      config:
        # avoid mirroring duplicate events on restarts or errors
        exactly.once.source.support: enabled
        # identities for resources that MM2 will create for internal use
        group.id: mm2-backup
        status.storage.topic: __mm2_backup_status
        offset.storage.topic: __mm2_backup_offsets
        config.storage.topic: __mm2_backup_configs
        status.storage.replication.factor: 3
        config.storage.replication.factor: 3
        offset.storage.replication.factor: 3
        key.converter: org.apache.kafka.connect.converters.ByteArrayConverter
        value.converter: org.apache.kafka.connect.converters.ByteArrayConverter
      tls:
        trustedCertificates:
          - certificate: ca.crt
            secretName: eu-eventstreams-cluster-ca-cert


  #-----------------------------------------
  # spec for the Mirror Maker pod
  #-----------------------------------------
  replicas: 1
  resources:
    requests:
      cpu: 2000m
      memory: 2Gi
    limits:
      cpu: 2000m
      memory: 2Gi
  template:
    pod:
      metadata:
        annotations:
          cloudpakId: c8b82d189e7545f0892db9ef2731b90d
          productVersion: 11.3.1
          productID: 2a79e49111f44ec3acd89608e56138f5
          cloudpakName: IBM Cloud Pak for Integration
          productChargedContainers: mm2-backup-mirrormaker2
          productCloudpakRatio: '2:1'
          productName: IBM Event Streams for Non Production
          eventstreams.production.type: CloudPakForIntegrationNonProduction
          productMetric: VIRTUAL_PROCESSOR_CORE