Setting up Kafka Mirror Maker for Kafka Topic Replication

Apache Kafka Mirror Maker 2 assists to replicate topics across Kafka clusters

Somnath Musib
3 min readNov 6, 2022


Image Courtesy: Unsplash by Jovis Aloor

In this article, we’ll demonstrate how to use Apache Mirror Maker to replicate Kafka Topics across two Kafka clusters.

Set Up

For demonstration, we’ll have the following set up:

  1. We’ll set up two Kafka clusters in two separate Kubernetes clusters (with AKS). You can refer to this article to set up the Kafka cluster in AKS. If you don’t want to use AKS/Kubernetes, you can also use local Kafka clusters
  2. We’ll use the Kafka built-in script to run Mirror Maker. However, in this article, we’ll run the script as a Kubernetes deployment

Configuring Mirror Maker

To start with, let us begin with the following folder structure:

First, let us configure the file. This file contains the details about the Kafka bootstrap servers, replication flows between clusters, and replication factors. The following shows the sample configuration. Make sure to update the bootstrap server details with your server details in the configuration file:

Next, let us define a Dockerfile to create a Docker image. The following snippet shows the sample docker file:

In the above Dokerfile, we are performing the following tasks:

  1. We’ve taken the ubuntu:latest as the base image
  2. Defined a few arguments…



Somnath Musib

Software Developer, Cloud Architect | Author "Spring Boot In Practice" . Find more at