Skip to content

[Enhancement]: KafkaMirrorMaker2 Tools #62

@kornys

Description

@kornys

Related problem

KafkaMirrorMaker2 manages cross-cluster replication for DR, geo-distribution, and migration. It extends KafkaConnect internally and manages MirrorSourceConnector, MirrorCheckpointConnector, and MirrorHeartbeatConnector. Critical for multi-cluster production setups.

Suggested solution

New Tools

list_kafka_mirror_makers

  • Parameters: namespace (optional)
  • Returns: List of MM2 instances: name, namespace, replicas (expected/ready), connect cluster name, source/target cluster names, status conditions
  • K8s CRD: kafkamirrormaker2s.kafka.strimzi.io

get_kafka_mirror_maker

  • Parameters: namespace (optional), mirrorMakerName (required)
  • Returns: Detailed MM2: replicas, connect cluster, clusters list (name, bootstrapServers, authentication type, TLS), mirrors (source cluster, target cluster, topic selectors, group selectors, sync group offsets config, checkpoint/heartbeat config), image, status conditions, connector statuses (from CR status)

get_kafka_mirror_maker_logs

  • Parameters: namespace (optional), mirrorMakerName (required), filter/keywords/sinceMinutes/tailLines (optional)
  • Returns: Aggregated MM2 pod logs with error analysis
  • Pod selection: strimzi.io/cluster={name}, strimzi.io/kind=KafkaMirrorMaker2
  • Reuses: LogCollectionService from common module

get_kafka_mirror_maker_pods

  • Parameters: namespace (optional), mirrorMakerName (required)
  • Returns: Pod summaries (reuses PodsService)

New Files

  • KafkaMirrorMaker2Service.java@ApplicationScoped
  • KafkaMirrorMaker2Tools.java@Singleton, @Guarded
  • KafkaMirrorMaker2Summary.java / KafkaMirrorMaker2Detail.java — DTOs
  • KafkaMirrorMaker2ServiceTest.java, KafkaMirrorMaker2ToolsTest.java
  • Update McpDiscoveryTest.java

RBAC

Add to 003-ClusterRole.yaml:

- apiGroups: ["kafka.strimzi.io"]
  resources: ["kafkamirrormaker2s"]
  verbs: ["get", "list", "watch"]

Key Notes

  • MM2 extends KafkaConnect so the CR structure shares many fields — reuse patterns from KafkaConnect Tools
  • Mirror config contains source/target cluster pairs with per-mirror topic and group selectors
  • Connector statuses (source, checkpoint, heartbeat) are embedded in CR status
  • Important to surface replication lag if available in connector status

Verification

  1. mvn clean test — new tests pass
  2. Deploy MM2 on dev cluster with two Kafka clusters
  3. Invoke list_kafka_mirror_makers, get_kafka_mirror_maker — verify cluster pairs and mirror configs
  4. Invoke get_kafka_mirror_maker_logs — verify log collection

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions