Skip to content

Interacting with Strimzi Kafka cluster through Kafka Bridge(2/n)

image image

Continuing from : (Deploying Basic Kafka cluster with the help of Strimzi operators (1/n))[https://naren4b.github.io/nks/docs/kafka-setup.html ]

Deploy a Kafka Topic (topic name: my-topic)

kubectl apply -n kafka -f https://raw.githubusercontent.com/strimzi/strimzi-kafka-operator/main/examples/topic/kafka-topic.yaml

Deploy a Kafka Bridge

kubectl apply -n kafka -f https://raw.githubusercontent.com/strimzi/strimzi-kafka-operator/main/examples/bridge/kafka-bridge.yaml

Deploy an Ingress

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: kafka-ingress-bridge
  namespace: kafka
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
    nginx.ingress.kubernetes.io/ssl-redirect: "false"
spec:
  rules:
    - host: kafka-bridge.local.com
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: my-bridge-bridge-service
                port:
                  number: 8080

Deploy a consumer

Notes: Run inside the cluster for the 'my-topic' Check the send messages are received

kubectl -n kafka run kafka-consumer -n kafka -ti --image=quay.io/strimzi/kafka:0.39.0-kafka-3.6.1 \
                                                     --rm=true --restart=Never -- bin/kafka-console-consumer.sh \
                                                     --bootstrap-server my-cluster-kafka-bootstrap:9092 \
                                                     --topic my-topic --from-beginning

Verifying the setup

Notes: Check the ingress(kafka-bridge.local.com) is accessiable let's post messages to our topic : 'my-topic'

 curl -X POST   http://kafka-bridge.local.com/topics/my-topic   -H 'content-type: application/vnd.kafka.json.v2+json'   -d '{
    "records": [
        {
            "key": "naren4b-key",
            "value": "hello from naren4b 0001"
        }
    ]
}'

image image

ref: https://strimzi.io/docs/bridge/latest/#proc-producing-messages-from-bridge-topics-partitions-bridge