# Kafka to Kafka Replicator

The K2K application is designed to facilitate seamless data replication between Kafka clusters while also replicating topic metadata. This capability ensures consistency across different environments or data centers. K2K supports a range of use cases including disaster recovery, data migration, and cross-datacenter data replication. By preserving both data and metadata, K2K enables a robust and efficient solution for maintaining synchronized Kafka clusters. Follow this [link](https://docs.lenses.io/latest/k2k/readme/uses-cases) to learn about the concepts.

Lenses streamlines K2K application management by simplifying creation and deployment, leading to faster and more efficient workflows. With self-service capabilities through [Kafka Connections](https://docs.lenses.io/latest/user-guide/applications/kafka-connections), users gain autonomy, improving productivity. Observability is enhanced through detailed throughput metrics, providing insights for optimized performance. Comprehensive governance is maintained with IAM policies, ensuring security and compliance.&#x20;

## Creating an application

For the moment, Lenses integration supports a subset of the K2K features. For example, via Lenses the user can replicate data to topics matching the source cluster. K2K support more complex topic name routing as described in the [standalone](https://docs.lenses.io/latest/k2k/configuration/target-partition) version.

The K2K application, integrated within Lenses, is configurable through a YAML file. The user interface offers auto-complete functionality to streamline YAML navigation, enhancing user efficiency. Alternatively, users can configure the application using the UI components.

To create the application, follow these steps.

{% stepper %}
{% step %}

### Navigate to the applications page

To access the applications page, select "Applications" from the user menu.

<figure><img src="https://880527424-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNwC1VSrH2RhBa4WJMBdQ%2Fuploads%2FyYQugG5BMLBmoRiwLQkn%2Fimage.png?alt=media&#x26;token=e3d9cb9a-cbe8-4faf-92ec-1083d7eaa1d9" alt=""><figcaption></figcaption></figure>

<br>
{% endstep %}

{% step %}

### Chose to create a new K2K application

Click on the "New" button to bring the options menu\
\
![](https://880527424-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNwC1VSrH2RhBa4WJMBdQ%2Fuploads%2FChNcQvbQInZhRG15N5BP%2Fimage.png?alt=media\&token=9140a626-2014-406f-8009-cf552315dc82)
{% endstep %}

{% step %}

### Configure it

Configure the application by selecting the source and target environments, choosing the topics to be replicated, and completing additional necessary settings.

<figure><img src="https://880527424-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNwC1VSrH2RhBa4WJMBdQ%2Fuploads%2FZ2kivt0EYySscHZSYL5b%2Fimage.png?alt=media&#x26;token=4815421c-a454-4ca9-99aa-314090d9ae94" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### Save and deploy

Once the application has been configured, click the save and deploy button to store and run the replication job.
{% endstep %}
{% endstepper %}

## Delete the K2K application

Navigate to the application details page and select "Delete" from the actions menu to remove the application. This will delete it from both Lenses and its Kubernetes deployment.

<figure><img src="https://880527424-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNwC1VSrH2RhBa4WJMBdQ%2Fuploads%2F2uK4qeNUHxZ1tMRgPCoo%2Fimage.png?alt=media&#x26;token=30f4902b-cfeb-46bf-a331-8dc1f05bbee9" alt=""><figcaption></figcaption></figure>

## Configuration Reference

This table outlines the complete set of fields for the K2K resource, which is utilized to define and configure a Kafka-to-Kafka application. The configuration is divided into two sections:

* **status**: Reflects the most recently observed state; it is read-only.
* **spec**: Depicts the intended state of the K2K application.

<table data-full-width="true"><thead><tr><th>Field</th><th width="248.4765625">Description</th><th width="247.0546875">Type</th><th>Default</th><th>Required</th></tr></thead><tbody><tr><td><code>spec.sourceKafkaLRN</code></td><td>Sets the source KafkaConnection LRN to read from.</td><td><code>string</code></td><td>(none)</td><td>Yes</td></tr><tr><td><code>spec.targetKafkaLRN</code></td><td>Sets the target KafkaConnection LRN to write to.</td><td><code>string</code></td><td>(none)</td><td>Yes</td></tr><tr><td><code>spec.topics</code></td><td>Sets the topic(s) to replicate.</td><td><code>array</code> (of <code>string</code>)</td><td>(none)</td><td>Yes</td></tr><tr><td><code>spec.deploymentNamespaceLRN</code></td><td>Defines the Kubernetes namespace to deploy to.</td><td><code>string</code></td><td>(none)</td><td>Yes</td></tr><tr><td><code>spec.kubernetes</code></td><td>Defines Kubernetes deployment overrides. (Ref: <code>K8sDeploymentOverrides</code>)</td><td><code>object</code></td><td>(none)</td><td>No</td></tr><tr><td><code>spec.replicator</code></td><td>Provides additional control knobs for the K2K replicator.</td><td><code>object</code></td><td>(none)</td><td>No</td></tr><tr><td><code>spec.paused</code></td><td>Halts replication by scaling down to zero pods.</td><td><code>boolean</code></td><td><code>false</code></td><td>No</td></tr><tr><td><code>spec.replicator.schemaMapping</code></td><td>Enables schema replication.</td><td><code>boolean</code></td><td><code>false</code></td><td>No</td></tr><tr><td><code>spec.replicator.exactlyOnce</code></td><td>Enables exactly-once processing.</td><td><code>boolean</code></td><td><code>false</code></td><td>No</td></tr><tr><td><code>spec.replicator.autoCreateTopics</code></td><td>Enables auto creation of topics.</td><td><code>boolean</code></td><td><code>false</code></td><td>No</td></tr><tr><td><code>spec.replicator.autoCreateControlTopics</code></td><td>Enables auto creation of control topics.</td><td><code>boolean</code></td><td><code>false</code></td><td>No</td></tr><tr><td><code>spec.replicator.keepRecordCreationTimestamp</code></td><td>Enables preserving record timestamps.</td><td><code>boolean</code></td><td><code>false</code></td><td>No</td></tr><tr><td><code>status.updatedAt</code></td><td>Contains the time instant this object was updated.</td><td><code>string</code> (date-time)</td><td>(none)</td><td>Yes</td></tr><tr><td><code>status.state</code></td><td>The high-level state of the application. (Ref: <code>K2KAppState</code>)</td><td><code>string</code></td><td>(none)</td><td>Yes</td></tr><tr><td><code>status.statusLastTransitionAt</code></td><td>Contains the time instant the status was changed.</td><td><code>string</code> (date-time)</td><td>(none)</td><td>Yes</td></tr><tr><td><code>status.statusMessage</code></td><td>Is a human-readable message indicating details about the last transition.</td><td><code>string</code></td><td>(none)</td><td>Yes</td></tr><tr><td><code>status.observedGeneration</code></td><td>Reflects the generation of the <code>spec</code> that this <code>status</code> corresponds to.</td><td><code>integer</code></td><td>(none)</td><td>Yes</td></tr><tr><td><code>status.deployment</code></td><td>Provides information about the Kubernetes deployment.</td><td><code>object</code></td><td>(none)</td><td>Yes</td></tr><tr><td><code>status.kafka</code></td><td>Provides information about the Kafka-related status.</td><td><code>object</code></td><td>(none)</td><td>Yes</td></tr><tr><td><code>status.deployment.inSync</code></td><td>Indicates if the deployed resources match the desired state.</td><td><code>boolean</code></td><td>(none)</td><td>Yes</td></tr><tr><td><code>status.deployment.managedResources</code></td><td>A list of resources managed by the deployment. (Ref: <code>KubernetesDeploymentStatusResource</code>)</td><td><code>array</code></td><td>(none)</td><td>Yes</td></tr><tr><td><code>status.deployment.pods</code></td><td>The status of the individual pods in the deployment. (Ref: <code>KubernetesDeploymentStatusPod</code>)</td><td><code>array</code></td><td>(none)</td><td>Yes</td></tr><tr><td><code>status.kafka.consumerGroup</code></td><td>Holds the name of the consumer group that this K2KApp uses.</td><td><code>string</code></td><td>(none)</td><td>Yes</td></tr></tbody></table>
