Skip to content

Commit 5e5b27b

Browse files
authored
MySQL CDC adapter and Kafka upserts (#2)
1 parent d617d4d commit 5e5b27b

File tree

28 files changed

+290
-54
lines changed

28 files changed

+290
-54
lines changed

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ COPY ./hoptimator-operator/run.sh ./hoptimator-operator
55
COPY ./hoptimator-cli/build/libs/hoptimator-cli-all.jar ./hoptimator-cli-all.jar
66
COPY ./hoptimator-operator/build/libs/hoptimator-operator-all.jar ./hoptimator-operator-all.jar
77
COPY ./etc/* ./
8-
COPY ./test-model.yaml ./test-model.yaml
98
ENTRYPOINT ["/bin/sh", "-c"]
10-
CMD ["./hoptimator"]
9+
CMD ["./hoptimator -n '' -p '' -u jdbc:calcite:model=model.yaml"]
10+

Makefile

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11

2-
bounce: build undeploy deploy
3-
42
build:
53
./gradlew build
64
docker build . -t hoptimator
75
docker build hoptimator-flink-runner -t hoptimator-flink-runner
86

9-
bounce: build undeploy deploy deploy-samples
7+
bounce: build undeploy deploy deploy-samples deploy-config
108

119
integration-tests:
1210
./bin/hoptimator --run=./integration-tests.sql
@@ -15,30 +13,35 @@ integration-tests:
1513
clean:
1614
./gradlew clean
1715

16+
deploy: deploy-config
17+
kubectl apply -f ./deploy
18+
1819
undeploy:
1920
kubectl delete -f ./deploy || echo "skipping"
21+
kubectl delete configmap hoptimator-configmap || echo "skipping"
2022

2123
quickstart: build deploy-dev-environment deploy
2224

2325
deploy-dev-environment:
2426
kubectl create -f https://github.com/jetstack/cert-manager/releases/download/v1.8.2/cert-manager.yaml || echo "skipping"
25-
helm repo add flink-operator-repo https://downloads.apache.org/flink/flink-kubernetes-operator-1.4.0/
26-
helm upgrade --atomic --set webhook.create=false flink-kubernetes-operator flink-operator-repo/flink-kubernetes-operator || helm install --atomic --set webhook.create=false flink-kubernetes-operator flink-operator-repo/flink-kubernetes-operator
2727
kubectl create namespace kafka || echo "skipping"
28+
kubectl create namespace mysql || echo "skipping"
29+
helm repo add flink-operator-repo https://downloads.apache.org/flink/flink-kubernetes-operator-1.4.0/
30+
helm upgrade --install --atomic --set webhook.create=false flink-kubernetes-operator flink-operator-repo/flink-kubernetes-operator
2831
kubectl apply -f "https://strimzi.io/install/latest?namespace=kafka" -n kafka
2932
kubectl apply -f "https://strimzi.io/examples/latest/kafka/kafka-ephemeral-single.yaml" -n kafka
3033
kubectl apply -f ./deploy/dev
3134

32-
deploy:
33-
kubectl apply -f ./deploy/
34-
3535
deploy-samples:
3636
kubectl apply -f ./deploy/samples
3737

38-
release:
39-
./gradlew publish
38+
deploy-config:
39+
kubectl create configmap hoptimator-configmap --from-file=model.yaml=test-model.yaml --dry-run=client -o yaml | kubectl apply -f -
4040

4141
generate-models:
4242
./models/generate-models.sh
4343

44-
.PHONY: build clean quickstart deploy-dev-environment deploy deploy-samples integration-tests bounce generate-models
44+
release:
45+
./gradlew publish
46+
47+
.PHONY: build clean quickstart deploy-dev-environment deploy deploy-samples deploy-config integration-tests bounce generate-models release

bin/hoptimator

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
#!/bin/sh
22

3-
docker build . -t hoptimator
4-
kubectl exec -it hoptimator -c hoptimator -- ./hoptimator -n "" -p "" -u "jdbc:calcite:model=./test-model.yaml" "$@"
5-
3+
kubectl exec -it hoptimator -c hoptimator -- ./hoptimator -n "" -p "" -u "jdbc:calcite:model=/etc/config/model.yaml" "$@"

deploy/dev/mysql.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: mysql
5+
namespace: mysql
6+
spec:
7+
ports:
8+
- port: 3306
9+
selector:
10+
app: mysql
11+
clusterIP: None
12+
13+
---
14+
15+
apiVersion: apps/v1
16+
kind: Deployment
17+
metadata:
18+
name: mysql
19+
namespace: mysql
20+
spec:
21+
selector:
22+
matchLabels:
23+
app: mysql
24+
strategy:
25+
type: Recreate
26+
template:
27+
metadata:
28+
labels:
29+
app: mysql
30+
spec:
31+
containers:
32+
- image: quay.io/debezium/example-mysql:2.2
33+
name: mysql
34+
env:
35+
- name: MYSQL_ROOT_PASSWORD
36+
value: debezium
37+
- name: MYSQL_USER
38+
value: mysqluser
39+
- name: MYSQL_PASSWORD
40+
value: mysqlpw
41+
ports:
42+
- containerPort: 3306
43+
name: mysql
44+

deploy/hoptimator-operator-deployment.yaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,12 @@ spec:
1818
- name: hoptimator-operator
1919
image: docker.io/library/hoptimator
2020
imagePullPolicy: Never
21-
command: ["./hoptimator-operator"]
21+
command: ["./hoptimator-operator", "/etc/config/model.yaml"]
22+
volumeMounts:
23+
- name: config-volume
24+
mountPath: /etc/config
25+
volumes:
26+
- name: config-volume
27+
configMap:
28+
name: hoptimator-configmap
2229

deploy/hoptimator-pod.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,14 @@ spec:
88
image: docker.io/library/hoptimator
99
imagePullPolicy: Never
1010
command: ["sleep", "infinity"]
11+
volumeMounts:
12+
- name: config-volume
13+
mountPath: /etc/config
1114
readinessProbe:
1215
exec:
1316
command: ["./hoptimator", "--run=./readiness-probe.sql"]
1417
timeoutSeconds: 30
15-
18+
volumes:
19+
- name: config-volume
20+
configMap:
21+
name: hoptimator-configmap

deploy/samples/subscriptions.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
apiVersion: hoptimator.linkedin.com/v1alpha1
22
kind: Subscription
33
metadata:
4-
name: people
4+
name: ceos
55
spec:
6-
sql: SELECT NAME FROM DATAGEN.PERSON
6+
sql: SELECT CEO, NAME AS KEY FROM DATAGEN.COMPANY
77
database: RAWKAFKA
88

99
---
1010

1111
apiVersion: hoptimator.linkedin.com/v1alpha1
1212
kind: Subscription
1313
metadata:
14-
name: companies
14+
name: companies
1515
spec:
16-
sql: SELECT NAME FROM DATAGEN.COMPANY
16+
sql: SELECT KEY AS PAYLOAD, PAYLOAD AS KEY FROM RAWKAFKA."ceos"
1717
database: RAWKAFKA
1818

1919
---
2020

2121
apiVersion: hoptimator.linkedin.com/v1alpha1
2222
kind: Subscription
2323
metadata:
24-
name: names
24+
name: products
2525
spec:
26-
sql: SELECT p.PAYLOAD || c.PAYLOAD FROM RAWKAFKA."people" p, RAWKAFKA."companies" c
26+
sql: SELECT "quantity", "product_id" AS KEY FROM INVENTORY."products_on_hand"
2727
database: RAWKAFKA
2828

2929

etc/integration-tests.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
!connect "jdbc:calcite:model=./test-model.yaml" "" ""
2+
!connect "jdbc:calcite:model=./model.yaml" "" ""
33

44
!set maxWidth 80
55
!table

etc/model.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# A default model with only built-in adapters
2+
3+
version: 1.0
4+
defaultSchema: DATAGEN
5+
schemas:
6+
7+
- name: DATAGEN
8+
type: custom
9+
factory: com.linkedin.hoptimator.catalog.builtin.DatagenSchemaFactory
10+

etc/readiness-probe.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
!connect "jdbc:calcite:model=./test-model.yaml" "" ""
2+
!connect "jdbc:calcite:model=./model.yaml" "" ""
33

44
!set maxWidth 80
55
!table

0 commit comments

Comments
 (0)