<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>

<ol>
<li><p><a href="https://docs.confluent.io/current/connect/connect-replicator/docs/index.html" rel="nofollow noreferrer">Replicator</a> is a commercial tool that enables you to replicate topics from one cluster to another. Similar to MirrorMaker though, it's designed to replicate <em>entire</em> topics, not just part of them.</p></li>
<li><p>You can use <a href="https://github.com/edenhill/kafkacat" rel="nofollow noreferrer">kafkacat</a> with <code>stdin</code>/<code>stdout</code> if you just want some kind of hacky option, but things like partitioning, topic config and all that stuff that you'd want to match for accurate testing you would have to ensure gets done properly.</p></li>
</ol>
