hoppity / kafka-http-proxy

A proxy that allows applications to use Kafka via HTTP written in NodeJS
Apache License 2.0
3 stars 4 forks source link

Connection Refused on 32400 #43

Open styk-tv opened 6 years ago

styk-tv commented 6 years ago

Startup fails with below error. Not sure where that address/port comes from. Zoo and kafka is up however no topics (maybe that has something to do with that). I'm attaching exception and at the bottom connectivity verification from rest pod.

Any suggestions would be cool.

events.js:141
      throw er; // Unhandled 'error' event
      ^

Error: connect ECONNREFUSED 172.174.30.177:32400
    at Object.exports._errnoException (util.js:856:11)
    at exports._exceptionWithHostPort (util.js:879:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1063:14)

Connectivity is there

root@kafka-rest-7d467d844b-6wqbw:/usr/local/src# 
root@kafka-rest-7d467d844b-6wqbw:/usr/local/src# ping pzoo
PING pzoo.kafka.svc.cluster.local (100.96.1.53): 56 data bytes
64 bytes from 100.96.1.53: icmp_seq=0 ttl=64 time=0.075 ms
64 bytes from 100.96.1.53: icmp_seq=1 ttl=64 time=0.106 ms
^C--- pzoo.kafka.svc.cluster.local ping statistics ---
2 packets transmitted, 2 packets received, 0% packet loss
round-trip min/avg/max/stddev = 0.075/0.090/0.106/0.000 ms
root@kafka-rest-7d467d844b-6wqbw:/usr/local/src# 
root@kafka-rest-7d467d844b-6wqbw:/usr/local/src# telnet pzoo 2181
Trying 100.96.1.53...
Connected to pzoo.kafka.svc.cluster.local.
Escape character is '^]'.
^]
telnet> 
ducas commented 6 years ago

Hi! A little more info on your configuration might be helpful. 32400 is the Plex port (according to google...) so I'm not sure how you're getting that either 😄

styk-tv commented 6 years ago

I'm launching your docker container from here https://hub.docker.com/r/hoppity/kafka-http-proxy/ in kubernetes in same namespace as kafka. I have only one kafka node and one zookeeper node but they are working fine and are resolvable. As to the configuration you can see above address is resolvable.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: kafka-rest
  namespace: kafka
spec:
  replicas: 1
  selector:
    matchLabels:
      app: kafka-rest
  template:
    metadata:
      labels:
        app: kafka-rest
    spec:
      containers:
      - name: kafka-rest
        image: hoppity/kafka-http-proxy
        ports:
        - containerPort: 8085
        env:
        - name: ZOOKEEPER_CONNECT
          value: pzoo:2181

above config is in exports

declare -x ZOOKEEPER_CONNECT="pzoo:2181"
ducas commented 6 years ago

Hi @styk-tv. Sorry for the delay, but I managed to get a kubes cluster running kafka, zk and the proxy using minikube. Unfortunately, I couldn't reproduce your problem...

First I started minikube with some extra RAM using minikube start --memory 4096.

Next I used the incubator/kafka helm chart to install kafka+zk with the following in mykafka.yaml -

replicas: 1
persistence:
  enabled: false
zookeeper:
  servers: 1

$ helm install incubator/kafka --name mykafka -f ./mykafka.yaml

Then I used the following yaml to create the deployment and a service -

apiVersion: apps/v1
kind: Deployment
metadata:
  name: kafka-rest
spec:
  replicas: 1
  selector:
    matchLabels:
      app: kafka-rest
  template:
    metadata:
      labels:
        app: kafka-rest
    spec:
      containers:
      - name: kafka-rest
        image: hoppity/kafka-http-proxy
        ports:
        - containerPort: 8085
        env:
        - name: ZOOKEEPER_CONNECT
          value: mykafka-zookeeper:2181
---
apiVersion: v1
kind: Service
metadata:
  name: kafka-rest
  labels:
    run: kafka-rest
spec:
  type: NodePort
  ports:
  - port: 8085
    targetPort: 8085
    protocol: TCP
  selector:
    app: kafka-rest

This exposed the service on port 32400. Everything started up and worked as expected.

Finally I posted to a topic -

$ curl -X POST \
     -H 'Content-Type: application/kafka.binary.v1+json' \
     -d '{"records":[{"value":"1234"}]}' \
     http://192.168.99.101:32400/topics/test

Which returned the response {"offsets":[{"partition":"0","offset":0}]}

Is there any more information your can give around how you built your cluster or your kafka/zk...?