0

I deploy confluent-kafka on openshift and I can open control-center on browser.

I deploy openshift via route on openshift.

I want to connect kafka broker as a consumer on different server.

So I deploy another route for kafka broker like this:

kind: Route
apiVersion: route.openshift.io/v1
metadata:
  name: kafka
  namespace: ttt
  annotations:
    openshift.io/host.generated: 'true' 
spec:
  host: kafka-xxx.apps.yyy.zzz
  to:
    kind: Service
    name: broker
    weight: 100
  port:
    targetPort: 9092-tcp
  tls:
    termination: passthrough
    insecureEdgeTerminationPolicy: Redirect

and my python code is :

from kafka import KafkaConsumer

if __name__ == '__main__':
    consumer = KafkaConsumer('my_topic_which_i_see_on_control_center', 
                             bootstrap_servers=['kafka-xxx.apps.yyy.zzz:443'],  
                             api_version=(0,10,2),
                             enable_auto_commit=True,  
                             security_protocol="SSL" ,
                             auto_commit_interval_ms=1000,
                             auto_offset_reset="earliest", 
                             group_id='ersin_test'
                            ) 
                            
    for msg in consumer:
        print(msg)

When I produce a message on control-center to that topic , I cant see any message on python.

Just wait on python.

How can I handle this?

Thanks in advance

CompEng
  • 7,161
  • 16
  • 68
  • 122
  • Kafka isn't an HTTPS service. Why are you trying to use port 443? Assuming you're running Strimzi on openshift, there's a documentation section on exposing access to the brokers – OneCricketeer Jan 30 '22 at 15:38
  • I created a route on openshift which linked 443 to 9092 – CompEng Jan 30 '22 at 17:51
  • Well, a Route is for HTTPS load balancing, not a TCP proxy, so why are you using it? Also, clients are still required tp communicate directly with brokers, so any proxy isn't going to work directly. If your app is deployed in k8s/openshift, just use the kafka service name via DNS – OneCricketeer Jan 31 '22 at 02:37
  • I can access in another pod on openshift it is fine but I want to access outside from the openshift so I cant reach via kafka service name, – CompEng Jan 31 '22 at 04:52
  • I've not used Openshift. A plain k8s Ingress should work for this, or exposing NodePort for each broker. Otherwise, I assume you've found posts like this? https://medium.com/operators/strimzi-kafka-openshift-routes-as-an-external-listener-8864f7b2ba11 – OneCricketeer Jan 31 '22 at 15:42

0 Answers0