Skip to content

Commit 7beb7eb

Browse files
convert demo cluster to Kubernetes (#9)
* started gutting docker-compose and got zookeeper working * fixing up cluster docs and yaml * working towards getting control-center set up in kubernetes * switched to arangodb operator * attempting to use the confluent operator for kubernetes * gave up on confluent operator * tried strimzi * switched to diy zookeeper * starting up diy kafka * added kafka connect * revamping demo readme * more work on the cluster * fixed kafka connect env values * refresh dependencies and clean up pom * test organization and general cleanup * renamed tests * fixed code coverage phase and dev docs * version fixes in demo and travisci java upgrade * more work on kubernetes cluster * improved demo documentation and cleaned up dependencies * added missing trailing newlines and kube-arangodb readme * upload Confluent Package to GitHub Release * switched properties loader for a version utility * updated dependencies * improved demo docs * updated changelog
1 parent 2ab64d7 commit 7beb7eb

File tree

45 files changed

+1491
-755
lines changed

Some content is hidden

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

45 files changed

+1491
-755
lines changed

.github/workflows/ci.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ jobs:
55
runs-on: ubuntu-latest
66
steps:
77
- uses: actions/checkout@v1
8-
- name: Set up JDK 1.8
8+
- name: Set up JDK 8
99
uses: actions/setup-java@v1
1010
with:
11-
java-version: 1.8
11+
java-version: 8
1212
- name: Cache Maven repository
1313
uses: actions/cache@v1
1414
with:

.github/workflows/release.yaml

+12-2
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ jobs:
88
runs-on: ubuntu-latest
99
steps:
1010
- uses: actions/checkout@v1
11-
- name: Set up JDK 11
11+
- name: Set up JDK 8
1212
uses: actions/setup-java@v1
1313
with:
14-
java-version: 1.8
14+
java-version: 8
1515
server-id: ossrh
1616
server-username: MAVEN_USERNAME
1717
server-password: MAVEN_PASSWORD
@@ -127,3 +127,13 @@ jobs:
127127
asset_path: target/kafka-connect-arangodb-${{ steps.deploy.outputs.version }}-javadoc.jar.asc
128128
asset_name: kafka-connect-arangodb-${{ steps.deploy.outputs.version }}-javadoc.jar.asc
129129
asset_content_type: text/plain
130+
- name: Upload Release Asset -- Confluent Package
131+
id: upload_release_asset_confluent_package
132+
uses: actions/[email protected]
133+
env:
134+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
135+
with:
136+
upload_url: ${{ steps.create_release.outputs.upload_url }}
137+
asset_path: target/components/packages/jaredpetersen-kafka-connect-arangodb-${{ steps.deploy.outputs.version }}.zip
138+
asset_name: jaredpetersen-kafka-connect-arangodb-${{ steps.deploy.outputs.version }}.zip
139+
asset_content_type: application/zip

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66
.project
77
target
88
dependency-reduced-pom.xml
9+
*.jar

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [1.0.6] - 2020-02-09
8+
### Changed
9+
- Switched development cluster to Kubernetes
10+
- Updated dependencies
11+
712
## [1.0.5] - 2020-02-02
813
### Changed
914
- Switched CI to GitHub Actions

checkstyle.xml

+305-234
Large diffs are not rendered by default.

config/quickstart-kafka-connect-arangodb-sink.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Kafka settings
22
name=arangodb-sink
3-
connector.class=com.mentor.kafka.kafkaconnectarangodb.sink.ArangoDBSinkConector
3+
connector.class=io.github.jaredpetersen.kafkaconnectarangodb.sink.ArangoDbSinkConnector
44
tasks.max=1
55

66
# Topics to consume from (comma-separated for a list of multiple topics)

docs/demo/README.md

+122
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
# Demo
2+
Let's run Kafka Connect ArangoDB in a local Apache Kafka + ArangoDB Kubernetes cluster via MiniKube so that we can get a feel for how it all works together.
3+
4+
## Setup
5+
### Minikube
6+
Let's set up the cluster. We're going to use Minikube for this so [make sure you have it installed](https://minikube.sigs.k8s.io/docs/start/) along with [`kubectl` 1.14 or higher](https://kubernetes.io/docs/tasks/tools/install-kubectl/).
7+
8+
Set up the cluster with a docker registry and some extra juice:
9+
```bash
10+
minikube start --cpus 2 --memory 10g
11+
```
12+
13+
### Docker
14+
Now that we have a cluster, we'll need a Docker image that contains the Kafka Connect ArangoDB plugin. We don't publish a Docker image to public Docker registries since you will usually install multiple Kafka Connect plugins on one image. Additionally, that base image may vary depending on your preferences and use case.
15+
16+
Navigate to `demo/docker/` and run the following commands in a separate terminal to download the plugin and build the image for Minikube:
17+
```bash
18+
curl -O https://search.maven.org/remotecontent?filepath=io/github/jaredpetersen/kafka-connect-arangodb/1.0.6/kafka-connect-arangodb-1.0.6.jar
19+
eval $(minikube docker-env)
20+
docker build -t jaredpetersen/kafka-connect-arangodb:1.0.6 .
21+
```
22+
23+
Close out this terminal when you're done -- we want to go back to our normal Docker environment.
24+
25+
Alternatively, build from source with `mvn package` at the root of this repository to get the JAR file.
26+
27+
### Kubernetes Manifests
28+
Let's start running everything. We're going to be using [kube-arangodb](https://github.com/arangodb/kube-arangodb) to help us manage our ArangoDB cluster and just plain manifests for Zookeeper, Apache Kafka, and Kafka Connect.
29+
30+
Apply the manifests (you may have to give this a couple of tries due to race conditions):
31+
```bash
32+
kubectl apply -k kubernetes
33+
```
34+
35+
Check in on the pods and wait for everything to come up:
36+
```bash
37+
kubectl -n kca-demo get pods
38+
```
39+
40+
Be patient, this can take a few minutes.
41+
42+
## Usage
43+
### Database
44+
Log in to the database. Minikube will take you there by running:
45+
```bash
46+
minikube -n kca-demo service arangodb-ea
47+
```
48+
49+
The username is `root` and the password is empty.
50+
51+
Create a new database with the name `demo`. Switch to this new database and create a document collection with the name `airports` and an edge collection with the name `flights`.
52+
53+
### Create Kafka Topics
54+
Create an interactive ephemeral query pod:
55+
```bash
56+
kubectl -n kca-demo run kafka-create-topics --generator=run-pod/v1 --image confluentinc/cp-kafka:5.4.0 -it --rm --command /bin/bash
57+
```
58+
59+
Create topics:
60+
```
61+
kafka-topics --create --zookeeper zookeeper-0.zookeeper:2181 --replication-factor 1 --partitions 1 --topic stream.airports
62+
kafka-topics --create --zookeeper zookeeper-0.zookeeper:2181 --replication-factor 1 --partitions 1 --topic stream.flights
63+
```
64+
65+
### Configure Kafka Connect ArangoDB
66+
Send a request to the Kafka Connect REST API to configure it to use Kafka Connect ArangoDB:
67+
```bash
68+
curl --request POST \
69+
--url "$(minikube -n kca-demo service kafka-connect --url)/connectors" \
70+
--header 'content-type: application/json' \
71+
--data '{
72+
"name": "demo-arangodb-connector",
73+
"config": {
74+
"connector.class": "io.github.jaredpetersen.kafkaconnectarangodb.sink.ArangoDbSinkConnector",
75+
"tasks.max": "1",
76+
"topics": "stream.airports,stream.flights",
77+
"arangodb.host": "arangodb-ea",
78+
"arangodb.port": 8529,
79+
"arangodb.user": "root",
80+
"arangodb.password": "",
81+
"arangodb.database.name": "demo"
82+
}
83+
}'
84+
```
85+
86+
### Write Records
87+
Create an interactive ephemeral query pod:
88+
```bash
89+
kubectl -n kca-demo run kafka-write-records --generator=run-pod/v1 --image confluentinc/cp-kafka:5.4.0 -it --rm --command /bin/bash
90+
```
91+
92+
Write records to the `airports` topic:
93+
```bash
94+
kafka-console-producer --broker-list kafka-broker-0.kafka-broker:9092 --topic stream.airports --property "parse.key=true" --property "key.separator=|"
95+
>{"id":"PDX"}|{"airport":"Portland International Airport","city":"Portland","state":"OR","country":"USA","lat":45.58872222,"long":-122.5975}
96+
>{"id":"BOI"}|{"airport":"Boise Airport","city":"Boise","state":"ID","country":"USA","lat":43.56444444,"long":-116.2227778}
97+
>{"id":"HNL"}|{"airport":"Daniel K. Inouye International Airport","city":"Honolulu","state":"HI","country":"USA","lat":21.31869111,"long":-157.9224072}
98+
>{"id":"KOA"}|{"airport":"Ellison Onizuka Kona International Airport at Keāhole","city":"Kailua-Kona","state":"HI","country":"USA","lat":19.73876583,"long":-156.0456314}
99+
```
100+
101+
Write records to the `flights` topic:
102+
```bash
103+
kafka-console-producer --broker-list kafka-broker-0.kafka-broker:9092 --topic stream.flights --property "parse.key=true" --property "key.separator=|"
104+
>{"id":1}|{"_from":"airports/PDX","_to":"airports/BOI","depTime":"2008-01-01T21:26:00.000Z","arrTime":"2008-01-01T22:26:00.000Z","uniqueCarrier":"WN","flightNumber":2377,"tailNumber":"N663SW","distance":344}
105+
>{"id":2}|{"_from":"airports/HNL","_to":"airports/PDX","depTime":"2008-01-13T00:16:00.000Z","arrTime":"2008-01-13T05:03:00.000Z","uniqueCarrier":"HA","flightNumber":26,"tailNumber":"N587HA","distance":2603}
106+
>{"id":3}|{"_from":"airports/KOA","_to":"airports/HNL","depTime":"2008-01-15T16:08:00.000Z","arrTime":"2008-01-15T16:50:00.000Z","uniqueCarrier":"YV","flightNumber":1010,"tailNumber":"N693BR","distance":163}
107+
>{"id":4}|{"_from":"airports/BOI","_to":"airports/PDX","depTime":"2008-01-16T02:03:00.000Z","arrTime":"2008-01-16T03:09:00.000Z","uniqueCarrier":"WN","flightNumber":1488,"tailNumber":"N242WN","distance":344}
108+
```
109+
110+
### Validate
111+
Open up the `demo` database again and go to the collections we created earlier. You should now see that they have the data we just wrote into Kafka.
112+
113+
## Teardown
114+
Remove all manifests:
115+
```bash
116+
k delete -k kubernetes
117+
```
118+
119+
Delete the minikube cluster
120+
```bash
121+
minikube delete
122+
```

docs/demo/docker/Dockerfile

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ARG VERSION=5.4.0
2+
FROM confluentinc/cp-kafka-connect-base:${VERSION}
3+
COPY kafka-connect-arangodb-*.jar /usr/share/java/kafka-connect-arangodb/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: database.arangodb.com/v1alpha
2+
kind: ArangoDeployment
3+
metadata:
4+
name: arangodb
5+
spec:
6+
mode: Cluster
7+
image: arangodb/arangodb:3.4.7
8+
externalAccess:
9+
type: NodePort
10+
tls:
11+
caSecretName: None
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# ArangoDB Kubernetes Operator
2+
All Kubernetes manifests in this directory are sourced from [kube-arangodb](https://github.com/arangodb/kube-arangodb) version 0.4.3.
3+
4+
These manifests are copied into the repository directly because Kustomize does not allow remote manifests and it's more convenient to run one `kubectl apply` command.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
---
2+
# Source: kube-arangodb-crd/templates/backup-policy.yaml
3+
apiVersion: apiextensions.k8s.io/v1beta1
4+
kind: CustomResourceDefinition
5+
metadata:
6+
name: arangobackuppolicies.backup.arangodb.com
7+
labels:
8+
app.kubernetes.io/name: kube-arangodb-crd
9+
helm.sh/chart: kube-arangodb-crd-0.4.3
10+
app.kubernetes.io/managed-by: Tiller
11+
app.kubernetes.io/instance: crd
12+
release: crd
13+
spec:
14+
group: backup.arangodb.com
15+
additionalPrinterColumns:
16+
- JSONPath: .spec.schedule
17+
description: Schedule
18+
name: Schedule
19+
type: string
20+
- JSONPath: .status.scheduled
21+
description: Scheduled
22+
name: Scheduled
23+
type: string
24+
- JSONPath: .status.message
25+
priority: 1
26+
description: Message of the ArangoBackupPolicy object
27+
name: Message
28+
type: string
29+
names:
30+
kind: ArangoBackupPolicy
31+
listKind: ArangoBackupPolicyList
32+
plural: arangobackuppolicies
33+
shortNames:
34+
- arangobackuppolicy
35+
- arangobp
36+
singular: arangobackuppolicy
37+
scope: Namespaced
38+
subresources:
39+
status: {}
40+
version: v1
41+
versions:
42+
- name: v1
43+
served: true
44+
storage: true
45+
- name: v1alpha
46+
served: true
47+
storage: false
48+
49+
---
50+
# Source: kube-arangodb-crd/templates/backup.yaml
51+
apiVersion: apiextensions.k8s.io/v1beta1
52+
kind: CustomResourceDefinition
53+
metadata:
54+
name: arangobackups.backup.arangodb.com
55+
labels:
56+
app.kubernetes.io/name: kube-arangodb-crd
57+
helm.sh/chart: kube-arangodb-crd-0.4.3
58+
app.kubernetes.io/managed-by: Tiller
59+
app.kubernetes.io/instance: crd
60+
release: crd
61+
spec:
62+
group: backup.arangodb.com
63+
additionalPrinterColumns:
64+
- JSONPath: .spec.policyName
65+
description: Policy name
66+
name: Policy
67+
type: string
68+
- JSONPath: .spec.deployment.name
69+
description: Deployment name
70+
name: Deployment
71+
type: string
72+
- JSONPath: .status.backup.version
73+
description: Backup Version
74+
name: Version
75+
type: string
76+
- JSONPath: .status.backup.createdAt
77+
description: Backup Creation Timestamp
78+
name: Created
79+
type: string
80+
- JSONPath: .status.backup.sizeInBytes
81+
description: Backup Size in Bytes
82+
name: Size
83+
type: integer
84+
format: byte
85+
- JSONPath: .status.backup.numberOfDBServers
86+
description: Backup Number of the DB Servers
87+
name: DBServers
88+
type: integer
89+
- JSONPath: .status.state
90+
description: The actual state of the ArangoBackup
91+
name: State
92+
type: string
93+
- JSONPath: .status.message
94+
priority: 1
95+
description: Message of the ArangoBackup object
96+
name: Message
97+
type: string
98+
names:
99+
kind: ArangoBackup
100+
listKind: ArangoBackupList
101+
plural: arangobackups
102+
shortNames:
103+
- arangobackup
104+
singular: arangobackup
105+
scope: Namespaced
106+
subresources:
107+
status: {}
108+
version: v1
109+
versions:
110+
- name: v1
111+
served: true
112+
storage: true
113+
- name: v1alpha
114+
served: true
115+
storage: false
116+
---
117+
# Source: kube-arangodb-crd/templates/deployment-replications.yaml
118+
apiVersion: apiextensions.k8s.io/v1beta1
119+
kind: CustomResourceDefinition
120+
metadata:
121+
name: arangodeploymentreplications.replication.database.arangodb.com
122+
labels:
123+
app.kubernetes.io/name: kube-arangodb-crd
124+
helm.sh/chart: kube-arangodb-crd-0.4.3
125+
app.kubernetes.io/managed-by: Tiller
126+
app.kubernetes.io/instance: crd
127+
release: crd
128+
spec:
129+
group: replication.database.arangodb.com
130+
names:
131+
kind: ArangoDeploymentReplication
132+
listKind: ArangoDeploymentReplicationList
133+
plural: arangodeploymentreplications
134+
shortNames:
135+
- arangorepl
136+
singular: arangodeploymentreplication
137+
scope: Namespaced
138+
version: v1
139+
versions:
140+
- name: v1
141+
served: true
142+
storage: true
143+
- name: v1alpha
144+
served: true
145+
storage: false
146+
---
147+
# Source: kube-arangodb-crd/templates/deployment.yaml
148+
apiVersion: apiextensions.k8s.io/v1beta1
149+
kind: CustomResourceDefinition
150+
metadata:
151+
name: arangodeployments.database.arangodb.com
152+
labels:
153+
app.kubernetes.io/name: kube-arangodb-crd
154+
helm.sh/chart: kube-arangodb-crd-0.4.3
155+
app.kubernetes.io/managed-by: Tiller
156+
app.kubernetes.io/instance: crd
157+
release: crd
158+
spec:
159+
group: database.arangodb.com
160+
names:
161+
kind: ArangoDeployment
162+
listKind: ArangoDeploymentList
163+
plural: arangodeployments
164+
shortNames:
165+
- arangodb
166+
- arango
167+
singular: arangodeployment
168+
scope: Namespaced
169+
version: v1
170+
versions:
171+
- name: v1
172+
served: true
173+
storage: true
174+
- name: v1alpha
175+
served: true
176+
storage: false

0 commit comments

Comments
 (0)