Yolean/kubernetes-kafka

Can't access Kafka outside of Kubernetes

Closed this issue · 9 comments

I've started Kafka using manifests from /configure, /zookeeper and kafka /kafka directories.

When I run services outside-0 - 3 I don't get any external IP

What am I doing wrong here?

this is my svc listing

NAME            TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)             AGE
svc/bootstrap   ClusterIP   10.108.85.149   <none>        9092/TCP            17h
svc/broker      ClusterIP   None            <none>        9092/TCP            17h
svc/outside-0   NodePort    10.96.121.223   <none>        32400:32400/TCP     12m
svc/outside-1   NodePort    10.102.27.147   <none>        32401:32401/TCP     12m
svc/outside-2   NodePort    10.111.151.46   <none>        32402:32402/TCP     12m
svc/pzoo        ClusterIP   None            <none>        2888/TCP,3888/TCP   20h
svc/zookeeper   ClusterIP   10.109.138.16   <none>        2181/TCP            20h

You need to change the services to LoadBalancer to get an external IP. Node port requires access to the nodes, on port 32400+ as seen in your svc listing.

You most likely also need to resolve outside listener names, i.e. FQDNs or IP addresses, in https://github.com/Yolean/kubernetes-kafka/blob/v3.1.0/kafka/10broker-config.yml#L30 based on your hosting situation. I think there are examples for AWS in #13 or #78.

I am going over #13 and #78 for days... It is really confusing. Is there any way to get short howto?

Nope, sorry. You're actually on your own. No howto can anticipate how you chose to expose these ports, how load balancing works in your cluster and how a shell script on the inside can figure out these external DNS-names or IP-addresses.

We used external-dns to setup our cluster quickly. You might want to check it out.

Thanks guys... I will try to do something with this. Hopefully it will work, so I can finally switch from Mesos to Kubernetes.

SamD commented

@dinoba
Depending on your deployment environment it might be a simple change, my current deployment is running k8s on AWS and for testing purposes I had setup a VPC with a public subnet where my cluster is.
In this case the minions will be assigned a public DNS entry by AWS so as mentioned by @solsson , in 10broker-config.yml I was able to change the script setting for OUTSIDE_HOST simply to use ExternalDNS vs InternalIP
e.g.

OUTSIDE_HOST=$(kubectl get node "$NODE_NAME" -o jsonpath='{.status.addresses[?(@.type=="ExternalDNS")].address}')

After doing so my external clients worked correctly

Hi @SamD
I'm working on Google GKE.
I've setup the same command but use "ExternalIP"

So in the server.properties of my brokers, i got something like this ::
advertised.listeners=OUTSIDE://x.x.x.156:32401,PLAINTEXT://:9092

When I'm trying to acces from the outside service with this port, i get TIMED OUT

node-1# curl x.x.x.156:32401
*** port 32401: Connection timed out

gcloudShell# curl x.x.x.156:32401
*** port 32401: Connection timed out

What's wrong ?

Thanks for help.

SamD commented

@maykiwo I haven't looked at this in a long time and haven't actually been working with k8s for sometime now. What shows in the in kubectl node addresses? Whatever you need should be in there so just substitute the correct type for ExternalDNS in the OUTPUT_HOST set script I specified and it should work.

@SamD, I'll try it. Thanks for reply.