<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Ricardo Domenzain</title>
    <description>The latest articles on Forem by Ricardo Domenzain (@rdomenzain).</description>
    <link>https://forem.com/rdomenzain</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F993750%2F88659e6a-1bab-46b0-af9e-232aa04f8701.JPG</url>
      <title>Forem: Ricardo Domenzain</title>
      <link>https://forem.com/rdomenzain</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/rdomenzain"/>
    <language>en</language>
    <item>
      <title>Kafka Ease: Simplifying Kafka Topic and ACL Management</title>
      <dc:creator>Ricardo Domenzain</dc:creator>
      <pubDate>Fri, 22 Sep 2023 23:09:15 +0000</pubDate>
      <link>https://forem.com/rdomenzain/kafka-ease-simplifying-kafka-topic-and-acl-management-p3e</link>
      <guid>https://forem.com/rdomenzain/kafka-ease-simplifying-kafka-topic-and-acl-management-p3e</guid>
      <description>&lt;p&gt;Kafka is a powerful distributed streaming platform, and managing topics and access control lists (ACLs) is a crucial part of Kafka administration. To make this task easier, I've created a Python library called Kafka Ease. Kafka Ease provides utilities to automate the creation of Kafka topics and ACLs, streamlining the administrative process.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzxaybtu83ciqirlq4alk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzxaybtu83ciqirlq4alk.png" alt="Automate Topic &amp;amp; ACL Management" width="800" height="190"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Features
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Create Kafka topics with a specified number of partitions and replication factor.&lt;/li&gt;
&lt;li&gt;Define ACLs (Access Control Lists) for Kafka topics, controlling who can perform various operations on them.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Getting Started
&lt;/h2&gt;

&lt;p&gt;To install Kafka Ease use the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install &lt;/span&gt;kafka-ease
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  How to Use Kafka Ease
&lt;/h3&gt;

&lt;h4&gt;
  
  
  File Format
&lt;/h4&gt;

&lt;p&gt;Kafka Ease uses YAML or JSON files for configuration. The configuration file must contain two main sections: &lt;code&gt;topics&lt;/code&gt; and &lt;code&gt;acls&lt;/code&gt;. Here's an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;topics&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;topic.name&lt;/span&gt;
    &lt;span class="na"&gt;num_partitions&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;
    &lt;span class="na"&gt;replication_factor&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;
    &lt;span class="na"&gt;cleanup_policy&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;delete&lt;/span&gt;
    &lt;span class="na"&gt;retention_days&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;7&lt;/span&gt;

&lt;span class="na"&gt;acls&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;resource_type&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;TOPIC&lt;/span&gt;
    &lt;span class="na"&gt;resource_name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;topic.name&lt;/span&gt;
    &lt;span class="na"&gt;principal&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;User:kafka-user&lt;/span&gt;
    &lt;span class="na"&gt;host&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;*"&lt;/span&gt;
    &lt;span class="na"&gt;operation&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;READ&lt;/span&gt;
    &lt;span class="na"&gt;permission_type&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ALLOW&lt;/span&gt;
    &lt;span class="na"&gt;pattern_type&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;LITERAL&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Topics Configuration
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;name&lt;/strong&gt;: Topic name&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;num_partitions&lt;/strong&gt;: Number of partitions&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;replication_factor&lt;/strong&gt;: Replication factor&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;cleanup_policy&lt;/strong&gt;: Cleanup policy (&lt;code&gt;delete&lt;/code&gt;, &lt;code&gt;compact&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;retention_days&lt;/strong&gt;: Delete retention days&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  ACLs Configuration
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;resource_type&lt;/strong&gt;: Resource type (&lt;code&gt;UNKNOWN&lt;/code&gt;, &lt;code&gt;ANY&lt;/code&gt;, &lt;code&gt;CLUSTER&lt;/code&gt;, &lt;code&gt;TOPIC&lt;/code&gt;, &lt;code&gt;DELEGATION_TOKEN&lt;/code&gt;, &lt;code&gt;GROUP&lt;/code&gt;, &lt;code&gt;TRANSACTIONAL_ID&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;resource_name&lt;/strong&gt;: Resource name&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;principal&lt;/strong&gt;: Principal (&lt;code&gt;User:&lt;/code&gt;, &lt;code&gt;Group:&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;host&lt;/strong&gt;: Host (*)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;operation&lt;/strong&gt;: Operation (&lt;code&gt;ANY&lt;/code&gt;, &lt;code&gt;ALL&lt;/code&gt;, &lt;code&gt;READ&lt;/code&gt;, &lt;code&gt;WRITE&lt;/code&gt;, &lt;code&gt;CREATE&lt;/code&gt;, &lt;code&gt;DELETE&lt;/code&gt;, &lt;code&gt;ALTER&lt;/code&gt;, &lt;code&gt;DESCRIBE&lt;/code&gt;, &lt;code&gt;CLUSTER_ACTION&lt;/code&gt;, &lt;code&gt;DESCRIBE_CONFIGS&lt;/code&gt;, &lt;code&gt;ALTER_CONFIGS&lt;/code&gt;, &lt;code&gt;IDEMPOTENT_WRITE&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;permission_type&lt;/strong&gt;: Permission type (&lt;code&gt;ANY&lt;/code&gt;, &lt;code&gt;DENY&lt;/code&gt;, &lt;code&gt;ALLOW&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;pattern_type&lt;/strong&gt;: Pattern type (&lt;code&gt;ANY&lt;/code&gt;, &lt;code&gt;MATCH&lt;/code&gt;, &lt;code&gt;LITERAL&lt;/code&gt;, &lt;code&gt;PREFIXED&lt;/code&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Validating Configuration
&lt;/h4&gt;

&lt;p&gt;To validate your configuration file, use the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kafka-ease apply &lt;span class="nt"&gt;-f&lt;/span&gt; acl.yaml &lt;span class="nt"&gt;--only-validate&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Expected output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;Validating file acl.yaml...
File: acl.yaml
YAML file detected
2 topics found.
2 ACLs found.
File acl.yaml is valid.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Applying Configuration
&lt;/h4&gt;

&lt;p&gt;To apply your configuration to Kafka, use a command like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kafka-ease apply &lt;span class="nt"&gt;-f&lt;/span&gt; acl.yaml &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--kafka-brokers&lt;/span&gt; kafka:9093 &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--security-protocol&lt;/span&gt; SASL_PLAINTEXT &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--sasl-mechanism&lt;/span&gt; SCRAM-SHA-256 &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--sasl-username&lt;/span&gt; kafka-admin &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--sasl-password&lt;/span&gt; SECRET
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Expected output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;Applying file...
Kafka brokers: kafka:9093
Security protocol: SASL_PLAINTEXT
SASL mechanism: SCRAM-SHA-256
SASL username: kafka-admin
SASL password: &lt;span class="k"&gt;***************&lt;/span&gt;
File: acl.yaml
YAML file detected
1 topics found.
1 ACLs found.
Topic topic.name updated
Removing old ACLs 3
ACL User:kafka-user synced
File synced successfully.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  More Information
&lt;/h2&gt;

&lt;p&gt;For more details and options, check out the &lt;a href="https://rdomenzain.github.io/kafka-ease/" rel="noopener noreferrer"&gt;documentation&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusions
&lt;/h2&gt;

&lt;p&gt;In conclusion, Kafka Ease is a valuable Python library that simplifies Kafka topic and ACL management. With its features for creating and configuring topics and access control lists, it significantly streamlines administrative tasks for Kafka administrators. This tool can be seamlessly integrated into your CI/CD (Continuous Integration/Continuous Deployment) pipeline to enhance the Kafka configuration deployment process.&lt;/p&gt;

&lt;p&gt;By incorporating Kafka Ease into your CI/CD pipeline, you can achieve the following benefits:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Automation:&lt;/strong&gt; Kafka Ease automates the creation and management of Kafka topics and ACLs, reducing the manual effort required for these tasks.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Consistency:&lt;/strong&gt; CI/CD pipelines ensure that Kafka configurations are consistently applied across different environments, reducing the risk of configuration errors.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Version Control:&lt;/strong&gt; With Kafka Ease configuration files under version control, changes to Kafka configurations can be tracked and reviewed, enhancing collaboration among team members.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Testing:&lt;/strong&gt; Before applying configurations to production Kafka clusters, you can thoroughly test them in staging or testing environments, ensuring the configurations work as expected.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Security:&lt;/strong&gt; Kafka Ease supports security protocols like SASL, allowing you to securely manage Kafka configurations in your CI/CD pipeline.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By integrating Kafka Ease into your CI/CD workflow, you can achieve a more efficient and controlled process for managing Kafka topics and ACLs across your Kafka clusters, ultimately enhancing the reliability and security of your Kafka infrastructure.&lt;/p&gt;

&lt;p&gt;GitHub Repository: &lt;a href="https://github.com/rdomenzain/kafka-ease" rel="noopener noreferrer"&gt;Kafka Ease on GitHub&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Happy Kafkaing! 🚀&lt;/p&gt;

</description>
      <category>python</category>
      <category>kafka</category>
      <category>automation</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
