Example app to read from a given Kafka topic and processing the message. Based on Apache Camel.
- Create a Cluster with a local registry and Kafka (e.g. via ./hack/create-kind-cluster.sh)
- Build and deploy the app to the local registry (localhost:5001):
mvn package - Apply manifests (and optionally adjust before):
kubectl apply -f target/kubernetes/kubernetes.yml - Test if messages get handled/logged:
- Produce some Kafka messages in the topic
kubectl -n kafka run kafka-producer --rm -ti --image=quay.io/strimzi/kafka:0.47.0-kafka-4.0.0 --rm=true --restart=Never -- bin/kafka-console-producer.sh --bootstrap-server my-cluster-kafka-bootstrap:9092 --topic my-topic - check the app logs
kubectl logs -l app.kubernetes.io/name: camel-app
- Produce some Kafka messages in the topic
It is possible to forward the messages to another Kafka Topic, which can be specified in the KAFKA_SINK_TOPIC_NAME env.
You can scale the app with KEDA to distribute the message processing on multiple instances.
- Apply the ScaledObject
kubectl apply -f keda-scaler.yaml - Produce some load on the Kafka topic
kubectl -n kafka run kafka-producer --rm -ti --image=quay.io/strimzi/kafka:0.47.0-kafka-4.0.0 --rm=true --restart=Never -- bin/kafka-producer-perf-test.sh --topic my-topic --num-records 100000 --record-size 10 --throughput -1 --producer-props bootstrap.servers=my-cluster-kafka-bootstrap:9092 - Check how the camel-app gets upscaled by KEDA:
kubectl get po -l app.kubernetes.io/name=camel-app -w