Skip to content

Commit 7428e6e

Browse files
committed
feat: kafka-gitops work and major refactor
1 parent a16d4ee commit 7428e6e

File tree

69 files changed

+1937
-530
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+1937
-530
lines changed

.github/workflows/gradle.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@ jobs:
2323
- name: Upload build artifact
2424
uses: actions/upload-artifact@v1
2525
with:
26-
name: kafka-dsf.jar
27-
path: build/libs/kafka-dsf-all.jar
26+
name: kafka-gitops.jar
27+
path: build/libs/kafka-gitops-all.jar

.github/workflows/release.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
- name: Build & Push Docker Image
2727
uses: mr-smithers-excellent/docker-build-push@v2
2828
with:
29-
image: devshawn/kafka-dsf
29+
image: devshawn/kafka-gitops
3030
tag: ${{ steps.get_version.outputs.VERSION }}
3131
registry: docker.io
3232
username: ${{ secrets.DOCKER_USERNAME }}
@@ -50,6 +50,6 @@ jobs:
5050
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5151
with:
5252
upload_url: ${{ steps.create_release.outputs.upload_url }}
53-
asset_path: ./build/distributions/kafka-dsf.zip
54-
asset_name: kafka-dsf.zip
53+
asset_path: ./build/distributions/kafka-gitops.zip
54+
asset_name: kafka-gitops.zip
5555
asset_content_type: application/zip

CONTRIBUTING.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Contributing
22

3-
Contributions are very welcome! Any existing issues labeled ["help wanted"](https://github.com/devshawn/kafka-dsf/labels/help%20wanted) or ["good first issue"](https://github.com/devshawn/kafka-dsf/labels/good%20first%20issue) are free to be pursued.
3+
Contributions are very welcome! Any existing issues labeled ["help wanted"](https://github.com/devshawn/kafka-gitops/labels/help%20wanted) or ["good first issue"](https://github.com/devshawn/kafka-gitops/labels/good%20first%20issue) are free to be pursued.
44

55
## Feature Requests & Bug Reports
66
For feature requests and bug reports, [submit an issue][issues].
@@ -17,5 +17,5 @@ The preferred way to contribute is to fork the [main repository][repository] on
1717
4. Once changes are completed, open a pull request for review against the master branch.
1818

1919

20-
[repository]: https://github.com/devshawn/kafka-dsf
21-
[issues]: https://github.com/devshawn/kafka-dsf/issues
20+
[repository]: https://github.com/devshawn/kafka-gitops
21+
[issues]: https://github.com/devshawn/kafka-gitops/issues

Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ FROM openjdk:8-slim
22

33
RUN apt-get update && apt-get install -y python3 python3-pip curl
44

5-
COPY ./build/libs/kafka-dsf-all.jar /usr/local/bin/kafka-dsf-all.jar
6-
COPY ./kafka-dsf /usr/local/bin/kafka-dsf
5+
COPY ./build/libs/kafka-gitops-all.jar /usr/local/bin/kafka-gitops-all.jar
6+
COPY ./kafka-gitops /usr/local/bin/kafka-gitops
77

README.md

+34-15
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# kafka-dsf
1+
# kafka-gitops
22

33
Manage Apache Kafka topics and ACLs through a desired state file.
44

@@ -8,22 +8,42 @@ Manage Apache Kafka topics and ACLs through a desired state file.
88

99
## Overview
1010

11-
This project allows you to manage Kafka topics and ACLs through use of a desired state file, much like Terraform and similar infrastructure-as-code projects.
11+
Kafka GitOps is an Apache Kafka resources-as-code tool which allows you to automate the management of your Apache Kafka topics and ACLs from version controlled code. It allows you to define topics and services through the use of a desired state file, much like Terraform and other infrastructure-as-code tools.
1212

13-
Topics and ACLs get defined in a YAML file. When run, `kafka-dsf` compares your desired state to the actual state of the cluster and generates a plan to execute against the cluster. This will make your topics and ACLs match your desired state.
13+
Topics and services get defined in a YAML file. When run, `kafka-gitops` compares your desired state to the actual state of the cluster and generates a plan to execute against the cluster. This will make your topics and ACLs match your desired state.
14+
15+
This tool also generates the needed ACLs for each type of application. There is no need to manually create a bunch of ACLs for Kafka Connect, Kafka Streams, etc. By defining your services, `kafka-gitops` will build the necessary ACLs.
16+
17+
This tool supports self-hosted Kafka, managed Kafka, and Confluent Cloud clusters.
18+
19+
## Features
20+
21+
- 🚀 **Built For CI/CD**: Made for CI/CD pipelines to automate the management of topics & ACLs.
22+
- 🔥 **Configuration as code**: Describe your desired state and manage it from a version-controlled declarative file.
23+
- 👍 **Easy to use**: Deep knowledge of Kafka administration or ACL management is **NOT** required.
24+
- ⚡️️ **Plan & Apply**: Generate and view a plan with or without executing it against your cluster.
25+
- 💻 **Portable**: Works across self-hosted clusters, managed clusters, and even Confluent Cloud clusters.
26+
- 🦄 **Idempotency**: Executing the same desired state file on an up-to-date cluster will yield the same result.
27+
- ☀️ **Continue from failures**: If a specific step fails during an apply, you can fix your desired state and re-run the command. You can execute `kafka-gitops` again without needing to rollback any partial successes.
28+
29+
## Getting Started
30+
31+
Documentation on how to install and use this tool can be found on our [documentation site][documentation].
1432

1533
## Usage
1634

17-
Run `kafka-dsf` to view the help output.
35+
Run `kafka-gitops` to view the help output.
1836

1937
```bash
20-
Usage: kafka-dsf [-hvV] [-f=<file>] [COMMAND]
38+
Usage: kafka-gitops [-hvV] [--no-delete] [-f=<file>] [COMMAND]
2139
Manage Kafka resources with a desired state file.
2240
-f, --file=<file> Specify the desired state file.
2341
-h, --help Display this help message.
42+
--no-delete Disable the ability to delete resources.
2443
-v, --verbose Show more detail during execution.
2544
-V, --version Print the current version of this tool.
2645
Commands:
46+
account Create Confluent Cloud service accounts.
2747
apply Apply changes to Kafka resources.
2848
plan Generate an execution plan of changes to Kafka resources.
2949
validate Validates the desired state file.
@@ -51,7 +71,7 @@ The following configuration is generated:
5171

5272
## State File
5373

54-
By default, `kafka-dsf` looks for `state.yaml` in the current directory. You can also use `kafka-dsf -f` to pass a file.
74+
By default, `kafka-gitops` looks for `state.yaml` in the current directory. You can also use `kafka-gitops -f` to pass a file.
5575

5676
An example desired state file:
5777

@@ -63,15 +83,13 @@ topics:
6383
configs:
6484
cleanup.policy: compact
6585

66-
acls:
67-
example-topic-read-acl:
68-
name: example-topic
69-
type: TOPIC
70-
pattern: LITERAL
71-
principal: User:super.admin
72-
host: "*"
73-
operation: WRITE
74-
permission: ALLOW
86+
services:
87+
example-service:
88+
type: application
89+
produces:
90+
- example-topic
91+
consumes:
92+
- example-topic
7593
```
7694
7795
## Contributing
@@ -84,5 +102,6 @@ Copyright (c) 2020 Shawn Seymour.
84102
85103
Licensed under the [Apache 2.0 license][license].
86104
105+
[documentation]: https://kafkagitops.devshawn.com
87106
[contributing]: ./CONTRIBUTING.md
88107
[license]: ./LICENSE

build.gradle

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
plugins {
22
id 'java'
3+
id 'groovy'
34
id 'application'
45
id 'idea'
56
id 'org.inferred.processors' version '1.2.10'
@@ -11,7 +12,7 @@ apply plugin: 'net.ltgt.apt-idea'
1112

1213
group 'com.devshawn'
1314

14-
mainClassName = 'com.devshawn.kafka.dsf.MainCommand'
15+
mainClassName = 'com.devshawn.kafka.gitops.MainCommand'
1516

1617
sourceCompatibility = 1.8
1718

@@ -33,20 +34,24 @@ dependencies {
3334
processor 'org.inferred:freebuilder:2.5.0'
3435

3536
testCompile group: 'junit', name: 'junit', version: '4.12'
37+
testCompile group: 'org.codehaus.groovy', name: 'groovy-all', version: '2.4.4'
38+
testCompile group: 'org.spockframework', name: 'spock-core', version: '1.0-groovy-2.4'
39+
testCompile group: 'cglib', name: 'cglib-nodep', version: '2.2'
40+
3641
}
3742

3843
jar {
3944
manifest {
4045
attributes(
4146
'Class-Path': configurations.compile.collect { it.getName() }.join(' '),
42-
'Main-Class': 'com.devshawn.kafka.dsf.MainCommand'
47+
'Main-Class': 'com.devshawn.kafka.gitops.MainCommand'
4348
)
4449
}
4550
}
4651

4752
task buildRelease(type: Zip, group: "build") {
4853
from("$buildDir/libs")
49-
from("./kafka-dsf")
54+
from("./kafka-gitops")
5055
}
5156

5257
buildRelease.dependsOn shadowJar

docs/.nojekyll

Whitespace-only changes.

docs/_coverpage.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
# kafka-gitops
3+
4+
> GitOps for Apache Kafka
5+
6+
- Automated Topic & ACL Management
7+
- Manage topics, services, and ACLs with desired state files
8+
9+
[Documentation](/documentation.md)

docs/_sidebar.md

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
- **Getting Started**
2+
- [Introduction](/documentation.md)
3+
- [Installation](/installation.md)
4+
- [Quick Start](/quick-start.md)
5+
- [Services](/services.md)
6+
- [Confluent Cloud](/confluent-cloud.md)
7+
- [Specification](/specification.md)
8+
- **Links**
9+
- [Contributing](https://github.com/devshawn/kafka-gitops/blob/master/CONTRIBUTING.md)
10+
- [GitHub](https://github.com/devshawn/kafka-gitops)

docs/confluent-cloud.md

+115
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
# Confluent Cloud
2+
3+
This tool was designed to work with Confluent Cloud. It can manage service accounts, topics, and ACLs for Confluent Cloud clusters.
4+
5+
## Getting Started
6+
7+
Ensure you have installed `kafka-gitops` or are using the `kafka-gitops` docker image as described in the [installation][installation] instructions.
8+
9+
You must have the `ccloud` command line tools installed if you wish to auto-populate the `principal` fields on services.
10+
11+
## Desired State File
12+
13+
Create a basic desired state file, `state.yaml`, such as:
14+
15+
```yaml
16+
settings:
17+
ccloud:
18+
enabled: true
19+
20+
topics:
21+
test-topic:
22+
partitions: 6
23+
replication: 3
24+
25+
services:
26+
test-service:
27+
type: application
28+
produces:
29+
- test-topic
30+
```
31+
32+
To give an overview, throughout this guide, this will create:
33+
34+
- A topic named `test-topic`
35+
- A service account named `test-service`
36+
- An `WRITE` ACL for topic `test-topic` tied to the service account `test-service`
37+
38+
## Configuration
39+
40+
To use `kafka-gitops` with Confluent Cloud, you'll need to set a few environment variables.
41+
42+
* `KAFKA_BOOTSTRAP_SERVERS`: Your Confluent Cloud cluster URL
43+
* `KAFKA_SASL_JAAS_USERNAME`: Your Confluent Cloud API key
44+
* `KAFKA_SASL_JAAS_USERNAME`: Your Confluent Cloud API secret
45+
* `KAFKA_SECURITY_PROTOCOL`: `SASL_SSL`
46+
* `KAFKA_SASL_MECHANISM`: `PLAIN`
47+
* `KAFKA_SSL_ENDPOINT_IDENTIFICATION_ALGORITHM`: `HTTPS`
48+
49+
Additionally, you'll need to login to the `ccloud` tool. You can automate this by setting the following environment variables:
50+
51+
* `XX_CCLOUD_EMAIL`: Your Confluent Cloud administrator email
52+
* `XX_CCLOUD_PASSWORD`: Your Confluent Cloud administrator password
53+
54+
Then, you can run `ccloud login` and it will run without a prompt. This is great for CI builds.
55+
56+
## Validate
57+
58+
First, validate your state file is correct by running:
59+
60+
```bash
61+
kafka-gitops -f state.yaml validate
62+
```
63+
64+
An example success message would look like:
65+
66+
```text
67+
[VALID] Successfully validated the desired state file.
68+
```
69+
70+
## Accounts
71+
72+
Before generating an execution plan, you will need to create the service accounts. This can be done by running:
73+
74+
```bash
75+
kafka-gitops -f state.yaml accounts
76+
```
77+
78+
This currently only creates service accounts; it will not delete any.
79+
80+
## Plan
81+
82+
We're now ready to generate a plan to execute against the cluster. By using the plan command, we are **NOT** changing the cluster.
83+
84+
Generate a plan by running:
85+
86+
```bash
87+
kafka-gitops -f state.yaml plan -o plan.json
88+
```
89+
90+
This will generate an execution plan to run against the cluster and save the output to `plan.json`.
91+
92+
The command will also pretty-print what changes it wants to make to the cluster.
93+
94+
## Apply
95+
96+
To execute a plan against the cluster, we use the apply command.
97+
98+
!> **WARNING**: This will apply changes to the cluster. This can be potentially destructive if you do not have all topics and ACLs defined.
99+
100+
By default, the apply command will generate a plan and then apply it. For most situations, **you should output a plan file from the plan command and pass it to the apply command**.
101+
102+
Example:
103+
104+
```bash
105+
kafka-gitops -f state.yaml apply -p plan.json
106+
```
107+
108+
Congrats! You're now using `kafka-gitops` to manage your Confluent Cloud cluster. Once you've practiced locally, you should commit your state file to a repository and create CI/CD pipelines to create plans and execute them against the cluster.
109+
110+
Welcome to GitOps!
111+
112+
113+
114+
115+
[installation]: /installation.md

docs/documentation.md

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<div align="center">
2+
<h1>GitOps for Apache Kafka</h1>
3+
<img src="https://i.imgur.com/eAIAv0w.png"/>
4+
<span>Manage Apache Kafka topics, services, and ACLs through a desired state file.</span>
5+
</div>
6+
7+
## Overview
8+
9+
Kafka GitOps is an Apache Kafka resources-as-code tool which allows you to automate the management of your Apache Kafka topics and ACLs from version controlled code. It allows you to define topics and services through the use of a desired state file, much like Terraform and other infrastructure-as-code tools.
10+
11+
Topics and services get defined in a YAML file. When run, `kafka-gitops` compares your desired state to the actual state of the cluster and generates a plan to execute against the cluster. This will make your topics and ACLs match your desired state.
12+
13+
This tool also generates the needed ACLs for each type of application. There is no need to manually create a bunch of ACLs for Kafka Connect, Kafka Streams, etc. By defining your services, `kafka-gitops` will build the necessary ACLs.
14+
15+
## Features
16+
17+
- 🚀 **Built For CI/CD**: Made for CI/CD pipelines to automate the management of topics & ACLs.
18+
- 🔥 **Configuration as code**: Describe your desired state and manage it from a version-controlled declarative file.
19+
- 👍 **Easy to use**: Deep knowledge of Kafka administration or ACL management is **NOT** required.
20+
- ⚡️️ **Plan & Apply**: Generate and view a plan with or without executing it against your cluster.
21+
- 💻 **Portable**: Works across self-hosted clusters, managed clusters, and even Confluent Cloud clusters.
22+
- 🦄 **Idempotency**: Executing the same desired state file on an up-to-date cluster will yield the same result.
23+
- ☀️ **Continue from failures**: If a specific step fails during an apply, you can fix your desired state and re-run the command. You can execute `kafka-gitops` again without needing to rollback any partial successes.
24+
25+
## Getting Started
26+
27+
Check out the **[Quick Start](/quick-start.md)** documentation to install `kafka-gitops` and get started.
28+
29+
## Ideology
30+
31+
The idea behind this project is to manage Kafka topics and ACLs through desired state files. These files define what your cluster should look like and `kafka-gitops` modifies your cluster's actual state to match the desired state file. Typically, this looks like:
32+
33+
- State files are stored in version control, such as a git repository.
34+
- Developers add, change, and remove topics & services from files and open a PR.
35+
- Operations teams valdiate and merge the PR.
36+
- A CI/CD pipeline generates a plan using `kafka-gitops`.
37+
- A human then validates the plan and applies the changes to the cluster.
38+
39+
## Contributing
40+
41+
Contributions are very welcome. See [CONTRIBUTING.md][contributing] for details.
42+
43+
## License
44+
45+
Copyright (c) 2020 Shawn Seymour.
46+
47+
Licensed under the [Apache 2.0 license][license].
48+
49+
[contributing]: https://github.com/devshawn/kafka-gitops/blob/master/CONTRIBUTING.md
50+
[license]: https://github.com/devshawn/kafka-gitops/blob/master/LICENSE

0 commit comments

Comments
 (0)