apiVersion: v1
kind: ConfigMap
metadata:
  name: mm2-config
data:
  connect-mirror-maker.properties: |
    clusters = A, B

    A.bootstrap.servers = my-source-cluster-kafka-bootstrap:9092
    B.bootstrap.servers = my-target-cluster-kafka-bootstrap:9092
    
    A->B.enabled = true
    A->B.topics = .*

    B->A.enabled = false
    # B->A.topics = .*

    replication.factor=1
    checkpoints.topic.replication.factor=1
    heartbeats.topic.replication.factor=1
    offset-syncs.topic.replication.factor=1
    offset.storage.replication.factor=1
    status.storage.replication.factor=1
    config.storage.replication.factor=1

    buffer.memory=7770101 
    producer.buffer.memory=7770102 
    producer.override.buffer.memory=7770103 
    source.cluster.producer.buffer.memory=7770104 
    source.cluster.buffer.memory=7770105 
    source.producer.buffer.memory=7770106
    target.cluster.producer.buffer.memory=7770107 
    target.cluster.buffer.memory=7770108 
    target.producer.buffer.memory=7770109 
    A.producer.buffer.memory=7770110 
    B.producer.buffer.memory=7770111 
    A.producer.override.buffer.memory=7770112
    B.producer.override.buffer.memory=7770113 


    fetch.max.bytes=55500101
    consumer.fetch.max.bytes=55500102
    consumer.override.fetch.max.bytes=55500103
    source.cluster.consumer.fetch.max.bytes=55500104
    source.cluster.fetch.max.bytes=55500105 
    source.consumer.fetch.max.bytes=55500106 
    target.cluster.consumer.fetch.max.bytes=55500107
    target.cluster.fetch.max.bytes=55500108 
    target.consumer.fetch.max.bytes=55500109
    A.consumer.fetch.max.bytes=55500110
    B.consumer.fetch.max.bytes=55500111
    A.consumer.override.fetch.max.bytes=55500112
    B.consumer.override.fetch.max.bytes=55500113


  log4j.properties: | 
    log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
    log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
    log4j.appender.CONSOLE.layout.ConversionPattern=%d{ISO8601} %p %X{connector.context}%m (%c) [%t]%n
    connect.root.logger.level=INFO
    log4j.rootLogger=${connect.root.logger.level}, CONSOLE
    log4j.logger.org.apache.zookeeper=ERROR
    log4j.logger.org.I0Itec.zkclient=ERROR
    log4j.logger.org.reflections=ERROR    
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: mirrormaker2
  labels:
    app: mirrormaker2
spec:
  replicas: 1
  selector:
    matchLabels:
      app: mirrormaker2
  template:
    metadata:
      labels:
        app: mirrormaker2
    spec:
      containers:
      - name: mirrormaker2
        image: "registry.redhat.io/amq7/amq-streams-kafka-31-rhel8:2.1.0" 
        command: ["/opt/kafka/bin/connect-mirror-maker.sh", "/opt/kafka/custom-config/connect-mirror-maker.properties", "--clusters", "B"]
        env:
        - name: "KAFKA_LOG4J_OPTS" 
          value: "-Dlog4j.configuration=file:/opt/kafka/custom-config/log4j.properties"
        - name: KAFKA_DEBUG
          value: "true"
        - name: JAVA_DEBUG_OPTS
          value: "-agentlib:jdwp=transport=dt_socket,address=5005,server=y,suspend=y"
        ports:
        - containerPort: 8083
          name: rest-api
          protocol: TCP
        volumeMounts:
        - mountPath: /opt/kafka/custom-config/
          name: mm2-config
      volumes:
      - configMap:
          defaultMode: 420
          name: mm2-config
        name: mm2-config
---
