Monedula

Declare mirror topics on a cluster link

Declare Confluent mirror topics with KafkaMirrorTopic, create them with apply, catch paused or failed mirrors with verify, and import existing ones.

How-to guides 17 of 21

6 min read

Updated 11 November 2026

Markdown

On this page

A KafkaMirrorTopic declares a mirror topic on the destination cluster of an existing Confluent cluster link. apply creates the mirror, verify reports when it stops replicating, and import brings existing mirrors into Git. The link itself stays yours: monedula-gitops never creates, pauses or deletes a link, and never pauses, resumes, promotes, fails over or deletes a mirror.

Before you start

  • monedula-gitops 1.1.0 or later.
  • A destination cluster on Confluent Server or Confluent Cloud with its Kafka REST v3 API reachable, and a cluster link on that destination. Apache Kafka has no cluster linking.
  • A principal for Kafka REST that may read the destination’s links and mirror topics and create mirror topics there. doctor checks the reads; the create permission shows up at the first apply.

Steps

1. Point the cluster config at Kafka REST

Mirror topics are created and read through Kafka REST, so the destination KafkaCluster needs a rest block next to its bootstrapServers:

apiVersion: gitops.monedula.dev/v1alpha1
kind: KafkaCluster
metadata:
  name: dest
spec:
  bootstrapServers: localhost:29092
  rest:
    endpoint: http://localhost:8090/kafka
  • endpoint is the base URL without /v3. On Confluent Server it usually ends in /kafka.
  • auth has the same shape as authorization.mds.auth: type: basic with a username and password, type: bearer with a token, or type: mtls. tls takes the same settings as the Kafka connection. Credentials are read with valueFrom, like the rest of the cluster config.
  • clusterId is optional on Confluent Platform, where the API is asked for it. Set it on Confluent Cloud. Either way, monedula-gitops checks that it equals the cluster ID the brokers report, and refuses to use mirror state from a REST API that serves a different cluster.

Once a cluster has rest, diff, apply and verify also read Kafka REST for every KafkaTopic on it, so that a KafkaTopic never changes a mirror (step 6). When Kafka REST cannot be read, they stop with exit code 2 instead of guessing.

monedula-gitops doctor --cluster-config-file ./clusters/dest.yaml

The rest, rest-cluster-binding and rest-mirrors checks pass, and each link on the cluster gets a link:<name> line with its state and prefix, for example link:src-to-dest. A link with auto.create.mirror.topics.enable=true is a warning, because it can create mirrors that no manifest declares. Check connectivity with doctor lists every check.

3. Declare the mirror

apiVersion: gitops.monedula.dev/v1alpha1
kind: KafkaMirrorTopic
metadata:
  name: orders-mirror
spec:
  clusterRef:
    name: dest
  linkName: src-to-dest
  sourceTopicName: orders
  • clusterRef names the destination cluster, where the link lives, and sourceTopicName the topic on the source cluster.
  • topicName is the name on the destination and defaults to sourceTopicName. When the link has a cluster.link.prefix, it must be set explicitly to the prefix followed by the source name, such as dr.orders.
  • replicationFactor is used only when the mirror is created. A different value on an existing mirror is reported as UnsupportedReplicationFactorChange and never changed.
  • config sets topic configs that are local to the mirror. A key that the link syncs from the source, through its topic.config.sync.include setting, is rejected; so is any key when the link does not report that setting, because then nobody can tell who owns it.
  • There is no partitions field: a mirror follows the source’s partitions.
  • reconciliation.mode works as on other kinds. deletionPolicy accepts only Orphan: removing the manifest, or deleting the resource in Kubernetes, always leaves the mirror topic in place.
  • clusterRef, linkName, sourceTopicName and the destination name cannot change. A topic name belongs to one resource per cluster: a KafkaTopic and a KafkaMirrorTopic with the same name are a duplicate, which validate rejects.

4. Create it with apply

monedula-gitops apply -f ./manifests --cluster-config-file ./clusters/dest.yaml

The plan shows CreateMirrorTopic. apply creates the mirror only when the destination topic does not exist yet, the link is ACTIVE and the name fits the link’s prefix; otherwise the plan shows Rejected with the reason, for example topic exists and is not a mirror when a normal topic already has that name, and apply exits 2. A changed local config shows as UpdateMirrorTopicConfig.

5. Watch its health with verify

monedula-gitops verify -f ./manifests --cluster-config-file ./clusters/dest.yaml

verify exits 0 while the mirror is ACTIVE. It reports, and never repairs:

Finding Mirror status verify
MirrorTopicUnhealthy PAUSED, LINK_PAUSED, FAILED, LINK_FAILED, SOURCE_UNAVAILABLE exits 1
MirrorTopicStopping PENDING_STOPPED, the mirror is being promoted or failed over exits 1
MirrorTopicPromoted STOPPED, the topic is now a normal, writable topic exits 1
MirrorTopicProgressing PENDING_MIRROR, PENDING_SYNCHRONIZE and the restore states exits 0, informational
StateReadError unknown, or Kafka REST could not be read exits 2

A mirror paused outside Git, for example with kafka-mirrors --pause, fails verify with MirrorTopicUnhealthy and the status PAUSED, and passes again once it is resumed. As with other kinds, ObserveOnly findings are shown without failing the run.

The operator re-checks every KafkaMirrorTopic at each resync, shows the live status in the Mirror column of kubectl get kafkamirrortopic, and reports MirrorTopicStalled when a transitional status stays unchanged for longer than mirrorStallThreshold, 30 minutes by default (Configure the Kubernetes operator). A KafkaMirrorTopic on a cluster without rest gets the condition ValidationFailed with the reason RESTNotConfigured.

6. Keep KafkaTopic away from mirrors

On a cluster with rest, a KafkaTopic whose topic is a live or stopping mirror is Rejected with manage it with KafkaMirrorTopic: no config change, no new partitions and no ACL created or pruned on that literal topic. A promoted mirror, STOPPED with its topic still there, is a normal topic again and can be managed by a KafkaTopic. Without rest, a KafkaTopic cannot tell a mirror from a normal topic, and doctor says so.

On the operator, a KafkaTopic with deletionPolicy: Delete never deletes a topic that is a mirror (Delete topics from Kubernetes).

7. Import existing mirrors

With rest in the cluster config, import cluster writes each mirror as a KafkaMirrorTopic with its link, source topic and replication factor, and never also as a KafkaTopic. Its summary warns, and marks the import partial, when it leaves something for you to review:

  • MirrorConfigNotImported: the mirror has configs set that the link does not sync. They may be local or may come from the source, so add the local ones to config yourself.
  • ExternallyManagedOrAmbiguousACLs: the link syncs ACLs, or its acl.sync.enable cannot be read, so the ACLs on the mirror are not imported. With ACL sync off, they are imported as a KafkaAccessPolicy.
  • MirrorImportDeferred: a mirror is PENDING_STOPPED. Run the import again once it finishes.
  • MirrorStaleEntry: Kafka REST still lists a stopped mirror whose topic no longer exists.

MirrorUnhealthy warns about a mirror that is imported but not ACTIVE, without making the import partial.

Check it worked

monedula-gitops verify -f ./manifests --cluster-config-file ./clusters/dest.yaml   # exits 0

verify exits 0, and records produced to orders on the source cluster can be consumed from orders on the destination.