<p>I have a Kafka cluster in <a href="https://kubernetes.io/" rel="nofollow noreferrer">kubernetes</a> with a lot of test data. I want to have some/all of that test data imported into my local Kafka cluster. This, way it would be easier for me to perform tests in the local environment with actual data from kubernetes.</p>

<p>So, is there a way to dump for eg: <em>5000 messages from a kafka topic</em> into a file and restore them into a local kafka topic ? </p>

<p>The way we do it (not on Kubernetes but it does not matter in this case) is:</p>

<ol>
<li>if we need to duplicate some part of data from our production cluster to a local/test cluster - we start a Flume agent that reads from prod Kafka cluster and pushes into test cluster. This only works with either live data (when you start your copy process now and let it run for whatever time is needed, capturing the live traffic), or if it is Ok to start getting data from the EARLIEST offset - because vanilla Flume per se does not allow you to specify specific range of offsets to consume from a topic (AFAIK)</li>
<li>if we do need data from a very specific range of offsets - we just run a very simple Java client (our own custom one, just a few lines of code) that seeks to the beginning offset and reads until the specified end offset of the source cluster/topic - and sends the events into the target Kafka cluster/topic</li>
</ol>

<p>we found these approaches simpler and more flexible that using more complex tools/frameworks like MirrorMaker.</p>
