:_mod-docs-content-type: CONCEPT

// Module included in the following assemblies:
//
// assembly-config.adoc

[id='con-config-mirrormaker2-{context}']
= Configuring MirrorMaker 2

[role="_abstract"]
Configure your MirrorMaker 2 deployment by updating the `spec` properties of the `KafkaMirrorMaker2` custom resource.

Start with a minimal configuration that defines the core requirements.
Extend it with optional settings to support the following:

* Securing connections (TLS and authentication)
* Managing of replicated topic names
* Synchronizing consumer group offsets
* Synchronizing ACL rules
* Tuning Kafka Connect worker settings
* xref:con-common-config-{context}[Common configuration], including setting resource limits and requests (recommended), JVM tuning, and metrics
* xref:assembly-logging-configuration-{context}[Logging configuration]

Certain settings, though optional, are recommended for production deployments, such as security and resource allocation.

For details of all configuration options, see the link:{BookURLConfiguring}[Strimzi Custom Resource API Reference^]. 

== Minimal configuration for MirrorMaker 2

A minimal `KafkaMirrorMaker2` resource requires the following in its spec:

* `.spec.target`: The connection details for the target Kafka cluster. Requires a unique alias. MirrorMaker 2 runs on the Kafka Connect framework, and its configuration and status are stored on this cluster.
* `.spec.mirrors`: The replication flow from a source cluster to a target cluster. 
* `.spec.mirrors[].source`: The connection details for the source Kafka cluster. Requires a unique alias.
* `.spec.replicas`: The number of Kafka Connect worker pods to deploy.

By default, MirrorMaker 2 replicates all topics and consumer groups.  
To reduce load on the cluster and avoid replicating unnecessary data, specify which topics and groups to include using filters:

* `topicsPattern`: A regex to select topics for replication.
* `groupsPattern`: A regex to select consumer groups for offset synchronization.

.Minimal configuration for KafkaMirrorMaker2
[source,yaml,subs="+attributes"]
----
# Basic configuration (required)
apiVersion: {KafkaMirrorMaker2ApiVersion}
kind: KafkaMirrorMaker2
metadata:
  name: my-mirror-maker2
spec:
  # Kafka version (recommended)
  version: {DefaultKafkaVersion}
  # Replicas (required)
  replicas: 3
  # Target / Connect cluster configuration (required)
  target:
    alias: "my-cluster-target"
    bootstrapServers: my-cluster-target-kafka-bootstrap:9092
    groupId: my-mirror-maker2-group
    configStorageTopic: my-mirror-maker2-config
    offsetStorageTopic: my-mirror-maker2-offset
    statusStorageTopic: my-mirror-maker2-status
  # Mirroring configurations (required)
  mirrors:
  - source:
      alias: "my-cluster-source"
      bootstrapServers: my-cluster-source-kafka-bootstrap:9092
    # Source connector configuration (required)
    sourceConnector: {}
    # Topic and group patterns (required)
    topicsPattern: "topic1.*|topic2.*"
    groupsPattern: "group1.*|group2-[0-9]{2}"
----

* `replicas` specifies the number of Kafka Connect worker replicas to run.
* `target` provides configuration for the target Kafka cluster. Kafka Connect uses this cluster to store internal topics.
* `target.alias` and `target.bootstrapServers` provide configuration used to identify the target Kafka cluster and specify its bootstrap addresses (host:port). For a Strimzi-managed cluster, you can use the bootstrap service name, for example `<cluster_name>-kafka-bootstrap:<port>`.
* `mirrors` defines replication between the source and target clusters.
* `source` provides configuration for the source Kafka cluster.
* `source.alias` and `source.bootstrapServers` provide configuration used to identify the source Kafka cluster and specify its bootstrap addresses (host:port). For a Strimzi-managed cluster, you can use the bootstrap service name, for example `<cluster_name>-kafka-bootstrap:<port>`.
* `sourceConnector` provides configuration for the source connector that replicates topics. An empty object uses the default configuration.
* `topicsPattern` configures replication for topics that start with `topic1` or `topic2`.
* `groupsPattern` configures replication for consumer groups that start with `group1` or `group2` followed by two digits.

NOTE: The Kafka clusters do not need to be managed by Strimzi or run on Kubernetes.

