Skip to content

Commit c39e65e

Browse files
authored
Fix various issues with SQL generation, flink job routing, integration-tests (#86)
* Fix Flink SQL syntax and ability to push jobs to session cluster * Update integration-test step * Fix hoptimator-operator crashing issue
1 parent 7c0455f commit c39e65e

File tree

19 files changed

+146
-54
lines changed

19 files changed

+146
-54
lines changed

.github/workflows/integration-tests.yml

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,24 +33,28 @@ jobs:
3333
kind load docker-image hoptimator
3434
kind load docker-image hoptimator-flink-runner
3535
kind load docker-image hoptimator-flink-operator
36-
- name: Deploy Dev Environment
37-
run: make deploy-dev-environment
38-
- name: Deploy Hoptimator
39-
run: make deploy
40-
- name: Deploy Samples
41-
run: make deploy-samples
42-
- name: Wait for Readiness
43-
run: kubectl wait kafka/one --for=condition=Ready --timeout=10m -n kafka
4436
- name: Run Integration Tests
45-
run: make integration-tests
37+
run: make integration-tests-kind
38+
- name: Capture Integration Reports
39+
if: failure()
40+
uses: actions/[email protected]
41+
with:
42+
name: reports
43+
path: |
44+
**/build/reports/tests/intTest/
4645
- name: Capture Cluster State
4746
if: always()
4847
run: |
49-
kubectl describe pods
50-
kubectl describe deployments
51-
kubectl describe kafkas -n kafka
52-
kubectl describe flinkdeployments
53-
kubectl describe subscriptions
48+
kubectl get pods
49+
kubectl get svc
50+
kubectl get deployments
51+
kubectl get pods -n kafka
52+
kubectl get svc -n kafka
53+
kubectl get deployments -n kafka
54+
kubectl get kafkas -n kafka
55+
kubectl get flinkdeployments
56+
kubectl get subscriptions
57+
kubectl get pipelines
5458
- name: Capture Flink Job Logs
5559
if: always()
5660
run: |

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@ FROM eclipse-temurin:18
22
WORKDIR /home/
33
ADD ./hoptimator-operator-integration/build/distributions/hoptimator-operator-integration.tar ./
44
ADD ./etc/* ./
5+
ENV POD_NAMESPACE_FILEPATH=/var/run/secrets/kubernetes.io/serviceaccount/namespace
56
ENTRYPOINT ["/bin/sh", "-c"]
67

Makefile

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ undeploy-config:
2525
deploy: deploy-config
2626
kubectl apply -f ./hoptimator-k8s/src/main/resources/
2727
kubectl apply -f ./deploy
28+
kubectl apply -f ./deploy/dev/rbac.yaml
2829

2930
undeploy: undeploy-config
31+
kubectl delete -f ./deploy/dev/rbac.yaml || echo "skipping"
3032
kubectl delete -f ./deploy || echo "skipping"
3133
kubectl delete -f ./hoptimator-k8s/src/main/resources/ || echo "skipping"
3234

@@ -64,16 +66,15 @@ undeploy-flink:
6466
kubectl delete crd flinkdeployments.flink.apache.org || echo "skipping"
6567
helm uninstall flink-kubernetes-operator || echo "skipping"
6668
helm repo remove flink-operator-repo || echo "skipping"
69+
kubectl delete -f https://github.com/jetstack/cert-manager/releases/download/v1.8.2/cert-manager.yaml || echo "skipping"
6770

6871
deploy-kafka: deploy deploy-flink
6972
kubectl create namespace kafka || echo "skipping"
7073
kubectl apply -f "https://strimzi.io/install/latest?namespace=kafka" -n kafka
7174
kubectl wait --for=condition=Established=True crds/kafkas.kafka.strimzi.io
72-
kubectl apply -f ./hoptimator-k8s/src/main/resources/
7375
kubectl apply -f ./deploy/dev
7476
kubectl apply -f ./deploy/samples/demodb.yaml
7577
kubectl apply -f ./deploy/samples/kafkadb.yaml
76-
kubectl delete -f https://github.com/jetstack/cert-manager/releases/download/v1.8.2/cert-manager.yaml || echo "skipping"
7778

7879
undeploy-kafka:
7980
kubectl delete kafkatopic.kafka.strimzi.io -n kafka --all || echo "skipping"
@@ -83,7 +84,6 @@ undeploy-kafka:
8384
kubectl delete -f ./deploy/samples/kafkadb.yaml || echo "skipping"
8485
kubectl delete -f ./deploy/samples/demodb.yaml || echo "skipping"
8586
kubectl delete -f ./deploy/dev || echo "skipping"
86-
kubectl delete -f ./hoptimator-k8s/src/main/resources/ || echo "skipping"
8787
kubectl delete namespace kafka || echo "skipping"
8888

8989
# Deploys Venice cluster in docker and creates two stores in Venice. Stores are not managed via K8s for now.
@@ -101,15 +101,22 @@ deploy-dev-environment: deploy deploy-flink deploy-kafka deploy-venice
101101

102102
undeploy-dev-environment: undeploy-venice undeploy-kafka undeploy-flink undeploy
103103

104-
# Integration tests expect K8s, Kafka, and Venice to be running
104+
# Integration test setup intended to be run locally
105105
integration-tests: deploy-dev-environment deploy-samples
106106
kubectl wait kafka.kafka.strimzi.io/one --for=condition=Ready --timeout=10m -n kafka
107107
kubectl wait kafkatopic.kafka.strimzi.io/existing-topic-1 --for=condition=Ready --timeout=10m -n kafka
108108
kubectl wait kafkatopic.kafka.strimzi.io/existing-topic-2 --for=condition=Ready --timeout=10m -n kafka
109-
kubectl port-forward -n kafka svc/one-kafka-external-0 9092 & echo $$! > port-forward.pid
109+
kubectl port-forward -n kafka svc/one-kafka-external-bootstrap 9092 & echo $$! > port-forward.pid
110110
./gradlew intTest || kill `cat port-forward.pid`
111111
kill `cat port-forward.pid`
112112

113+
# kind cluster used in github workflow needs to have different routing set up, avoiding the need to forward kafka ports
114+
integration-tests-kind: deploy-dev-environment deploy-samples
115+
kubectl wait kafka.kafka.strimzi.io/one --for=condition=Ready --timeout=10m -n kafka
116+
kubectl wait kafkatopic.kafka.strimzi.io/existing-topic-1 --for=condition=Ready --timeout=10m -n kafka
117+
kubectl wait kafkatopic.kafka.strimzi.io/existing-topic-2 --for=condition=Ready --timeout=10m -n kafka
118+
./gradlew intTest
119+
113120
generate-models:
114121
./generate-models.sh
115122
./hoptimator-models/generate-models.sh # <-- marked for deletion
@@ -118,4 +125,4 @@ release:
118125
test -n "$(VERSION)" # MISSING ARG: $$VERSION
119126
./gradlew publish
120127

121-
.PHONY: install test build bounce clean quickstart deploy-config undeploy-config deploy undeploy deploy-demo undeploy-demo deploy-samples undeploy-samples deploy-flink undeploy-flink deploy-kafka undeploy-kafka deploy-venice undeploy-venice integration-tests deploy-dev-environment undeploy-dev-environment generate-models release
128+
.PHONY: install test build bounce clean quickstart deploy-config undeploy-config deploy undeploy deploy-demo undeploy-demo deploy-samples undeploy-samples deploy-flink undeploy-flink deploy-kafka undeploy-kafka deploy-venice undeploy-venice integration-tests integration-tests-kind deploy-dev-environment undeploy-dev-environment generate-models release

README.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,22 @@ The below setup will create a dev environment with various resources within Kube
5555
```
5656
$ make install # build and install SQL CLI
5757
$ make deploy-dev-environment # start all local dev setups
58-
$ kubectl port-forward -n kafka svc/one-kafka-external-0 9092 & # forward external Kafka port for use by SQL CLI
58+
$ kubectl port-forward -n kafka svc/one-kafka-external-bootstrap 9092 & # forward external Kafka port for use by SQL CLI
5959
$ ./hoptimator # start the SQL CLI
6060
> !intro
6161
```
6262

6363
Commands `deploy-kafka`, `deploy-venice`, `deploy-flink`, etc. exist in isolation to deploy individual components.
6464

65+
### Kafka
66+
67+
To produce/consume Kafka data, use the following commands:
68+
69+
```
70+
$ kubectl run kafka-producer -ti --image=quay.io/strimzi/kafka:0.45.0-kafka-3.9.0 --rm=true --restart=Never -- bin/kafka-console-producer.sh --bootstrap-server one-kafka-bootstrap.kafka.svc.cluster.local:9094 --topic existing-topic-1
71+
$ kubectl run kafka-consumer -ti --image=quay.io/strimzi/kafka:0.45.0-kafka-3.9.0 --rm=true --restart=Never -- bin/kafka-console-consumer.sh --bootstrap-server one-kafka-bootstrap.kafka.svc.cluster.local:9094 --topic existing-topic-1 --from-beginning
72+
```
73+
6574
### Flink
6675

6776
```
@@ -80,6 +89,26 @@ to access the Flink dashboard.
8089
See the [Flink SQL Gateway Documentation](https://nightlies.apache.org/flink/flink-docs-release-1.18/docs/dev/table/sql-gateway/overview/)
8190
for sample adhoc queries through Flink.
8291

92+
To push a Flink job directly to the Flink deployment created above, `kubectl apply` the following yaml:
93+
```
94+
apiVersion: flink.apache.org/v1beta1
95+
kind: FlinkSessionJob
96+
metadata:
97+
name: test-flink-session-job
98+
spec:
99+
deploymentName: basic-session-deployment
100+
job:
101+
entryClass: com.linkedin.hoptimator.flink.runner.FlinkRunner
102+
args:
103+
- CREATE TABLE IF NOT EXISTS `datagen-table` (`KEY` VARCHAR, `VALUE` BINARY) WITH ('connector'='datagen', 'number-of-rows'='10');
104+
- CREATE TABLE IF NOT EXISTS `existing-topic-1` (`KEY` VARCHAR, `VALUE` BINARY) WITH ('connector'='kafka', 'properties.bootstrap.servers'='one-kafka-bootstrap.kafka.svc.cluster.local:9094', 'topic'='existing-topic-1', 'value.format'='json');
105+
- INSERT INTO `existing-topic-1` (`KEY`, `VALUE`) SELECT * FROM `datagen-table`;
106+
jarURI: file:///opt/hoptimator-flink-runner.jar
107+
parallelism: 1
108+
upgradeMode: stateless
109+
state: running
110+
```
111+
83112
## The SQL CLI
84113

85114
The `./hoptimator` script launches the [sqlline](https://github.com/julianhyde/sqlline) SQL CLI pre-configured to connect to `jdbc:hoptimator://`. The CLI includes some additional commands. See `!intro`.

deploy/dev/kafka.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ spec:
3030
port: 9094
3131
type: internal
3232
tls: false
33+
configuration:
34+
useServiceDnsDomain: true
3335
- name: tls
3436
port: 9093
3537
type: internal
@@ -39,9 +41,12 @@ spec:
3941
type: nodeport
4042
tls: false
4143
configuration:
44+
bootstrap:
45+
nodePort: 31092
4246
brokers:
4347
- broker: 0
44-
advertisedHost: localhost
48+
advertisedHost: 127.0.0.1
49+
nodePort: 31234
4550
config:
4651
offsets.topic.replication.factor: 1
4752
transaction.state.log.replication.factor: 1

deploy/dev/rbac.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
apiVersion: rbac.authorization.k8s.io/v1
2-
kind: RoleBinding
2+
kind: ClusterRoleBinding
33
metadata:
44
name: hoptimator-operator
55
namespace: default
@@ -8,6 +8,6 @@ subjects:
88
name: hoptimator-operator
99
namespace: default
1010
roleRef:
11-
kind: Role
11+
kind: ClusterRole
1212
name: hoptimator-operator
1313
apiGroup: rbac.authorization.k8s.io

deploy/docker/venice/docker-compose-single-dc-setup.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ services:
1616
hostname: kafka
1717
environment:
1818
- ZOOKEEPER_ADDRESS=zookeeper:2181
19+
ports:
20+
- 9095:9092
1921
depends_on:
2022
zookeeper:
2123
condition: service_healthy

deploy/rbac.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
apiVersion: rbac.authorization.k8s.io/v1
2-
kind: Role
2+
kind: ClusterRole
33
metadata:
44
namespace: default
55
name: hoptimator-operator
66
rules:
77
- apiGroups: ["hoptimator.linkedin.com"]
8-
resources: ["acls", "kafkatopics", "subscriptions", "sqljobs"]
8+
resources: ["acls", "kafkatopics", "subscriptions", "sqljobs", "pipelines"]
99
verbs: ["get", "watch", "list", "update", "create"]
1010
- apiGroups: ["hoptimator.linkedin.com"]
11-
resources: ["kafkatopics/status", "subscriptions/status", "acls/status", "sqljobs/status"]
11+
resources: ["kafkatopics/status", "subscriptions/status", "acls/status", "sqljobs/status", "pipelines/status"]
1212
verbs: ["get", "patch"]
1313
- apiGroups: ["flink.apache.org"]
14-
resources: ["flinkdeployments"]
14+
resources: ["flinkdeployments", "flinksessionjobs"]
1515
verbs: ["get", "update", "create"]
1616

deploy/samples/flinkDeployment.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ kind: FlinkDeployment
33
metadata:
44
name: basic-session-deployment
55
spec:
6-
image: flink:1.18
6+
image: docker.io/library/hoptimator-flink-runner
7+
imagePullPolicy: Never
78
flinkVersion: v1_18
89
flinkConfiguration:
9-
taskmanager.numberOfTaskSlots: "1"
10+
taskmanager.numberOfTaskSlots: "3"
1011
serviceAccount: flink
1112
jobManager:
1213
resource:

deploy/samples/kafkadb.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ spec:
3434
connector: |
3535
connector = kafka
3636
topic = {{table}}
37-
properties.bootstrap.servers = localhost:9092
37+
properties.bootstrap.servers = one-kafka-bootstrap.kafka.svc.cluster.local:9094
38+
value.format = json
39+
scan.startup.mode = earliest-offset
3840
3941
---
4042

0 commit comments

Comments
 (0)