Lab: Install Kafka Bridge
Task 1: Install Kafka Bridge
Install the Kafka Bridge to your cluster using its CRD.
It should limit to 2Gi of RAM and 200m of CPU.
Use the kafka-cluster-cluster-ca-cert and the cluster-tls-managed.
The bridge needs an user to connect to the Kafka Cluster. This user should have access to all topics and consumer groups.
Use the scram-sha-512 authentication with a new user.
https://strimzi.io/docs/operators/latest/deploying#deploying-kafka-bridge-str
Hint 1
If you need a good starting point look into the examples directory of the strimzi repo. It contains example BRIDGE configs. Also look in the security folder of the examples. For the User: give the user access to all topics and consumer groups.
Hint 3
apiVersion: kafka.strimzi.io/v1beta2
kind: KafkaUser
metadata:
name: kafka-bridge
labels:
strimzi.io/cluster: kafka-cluster
spec:
authentication:
type: scram-sha-512
authorization:
type: simple
acls:
- resource:
type: group
name: "*"
patternType: literal
operations:
- Read
- resource:
type: topic
name: "*"
patternType: literal
operations:
- Read
- Write
- Describe
---
apiVersion: kafka.strimzi.io/v1beta2
kind: KafkaBridge
metadata:
name: bridge
spec:
replicas: 1
bootstrapServers: cluster-1-kafka-bootstrap.{your namespace}.svc:9092
http:
port: 8080
authentication:
type: scram-sha-512
username: kafka-bridge
passwordSecret:
secretName: kafka-bridge
password: password
Task 2: List Topics
Use the Kafka Bridge to list all topics.
Use a session on one of the running pods in the cluster in your namespace.
https://strimzi.io/docs/bridge/latest/#assembly-kafka-bridge-quickstart-bridge
Hint 1
https://strimzi.io/docs/bridge/latest/#proc-producing-messages-from-bridge-topics-partitions-bridge
Hint 2
curl -X GET http://{bridge-host}:8080/topics
Hint 3
ask the trainer
Task 3: Produce Message
Use the Kafka Bridge to produce a message to a “test-0” topic. e.g. Key: blah Value: {“msg”:”hello-bridge”}
Use a session on one of the running pods in the cluster in your namespace.
https://strimzi.io/docs/bridge/latest/#assembly-kafka-bridge-quickstart-bridge
Hint 1
https://strimzi.io/docs/bridge/latest/#proc-producing-messages-from-bridge-topics-partitions-bridge
Hint 2
curl -X POST -H "Content-Type: application/vnd.kafka.json.v2+json" --data '{"records":[{"key":"blah","value":{"msg":"hello-bridge"}}]}' http://bridge-bridge-service.{your namespace}:8080/topics/test-0
Hint 3
ask the trainer
Task 4: Consume Message
Use the Kafka Bridge to consume a message from the “bridge-test” topic using the my-bridge consumer group.
Use a session on one of the running pods in the cluster in your namespace.
Hint 1
-
Create a consumer https://strimzi.io/docs/bridge/latest/#proc-creating-kafka-bridge-consumer-bridge
-
Subscribe consumer to topic https://strimzi.io/docs/bridge/latest/#proc-bridge-subscribing-consumer-topics-bridge
-
Consume latest message https://strimzi.io/docs/bridge/latest/#proc-bridge-retrieving-latest-messages-from-consumer-bridge
Hint 2
-
Create a consumer
curl -X POST http://bridge-bridge-service.{your namespace}:8080/consumers/my-bridge \ -H 'content-type: application/vnd.kafka.v2+json' \ -d '{ "name": "my-consumer", "auto.offset.reset": "earliest", "format": "json", "enable.auto.commit": true, "fetch.min.bytes": 512, "consumer.request.timeout.ms": 30000 }' -
Subscribe consumer to topic
curl -X POST http://bridge-bridge-service.{your namespace}:8080/consumers/my-bridge/instances/my-consumer/subscription \ -H 'content-type: application/vnd.kafka.v2+json' \ -d '{ "topics": [ "topic-0" ] }' -
Consume latest message {you may need to execute the following command multiple times to receive messages}
curl -X GET http://bridge-bridge-service.{your namespace}:8080/consumers/my-bridge/instances/my-consumer/records \ -H 'accept: application/vnd.kafka.json.v2+json'
Hint 3
ask the trainer