I solved this problem using the Confluent Kafka REST proxy file.
https://hub.docker.com/r/confluentinc/cp-kafka-rest/
The REST proxy documentation is here:
http://docs.confluent.io/3.1.2/kafka-rest/docs/index.html
Step A: Create a Kafka brokerage company docker image using the latest version of Kafka
I used a custom Kafka broker image based on the same image that you used. You just need to update your cloudtrackinc image to use Kafka version 0.10.1.0 or else it will not work. Just update the Docker file from the cloudertrackinc image to use the latest kurka wurstmeister image and rebuild the docker image.
- FROM wurstmeister/kafka:0.10.1.0
I set ADVERTISED_HOST_NAME for each Kafka broker on the POD IP so that each broker gets a unique URL.
- name: ADVERTISED_HOST_NAME valueFrom: fieldRef: fieldPath: status.podIP
Step B: Install the cp-kafka-rest proxy to use the Kafka broker cluster
The Kafka Rest proxy server must run in the same cluster as your Kafka broker cluster.
You need to provide two environment variables for the cp-kafka-rest image at least to run. KAFKA_REST_HOST_NAME and KAFKA_REST_ZOOKEEPER_CONNECT. You can set KAFKA_REST_HOST_NAME to use POD IP.
- name: KAFKA_REST_HOST_NAME valueFrom: fieldRef: fieldPath: status.podIP - name: KAFKA_REST_ZOOKEEPER_CONNECT value: "zookeeper-svc-1:2181,zookeeper-svc-2:2181,zookeeper-svc-3:2181"
Step C: Run Kafka REST Proxy as a Service
spec: type: NodePort or LoadBalancer ports: - name: kafka-rest-port port: 8082 protocol: TCP
You can use NodePort or LoadBalancer to use one or more Kafka POS proxy modules.
Pros and cons of using the Kafka REST proxy server
Pros:
- You can easily scale the Kafka broker cluster.
- You do not need to expose Kakfa brokers outside the cluster
- You can use a loadbalancer with a proxy.
- You can use any type of client to access the Kafka cluster (i.e. waving). Very light weight.
Minuses:
- Another component / layer on top of the Kakfa cluster.
- Consumers are created within the proxy server. This will need to be tracked by your REST client.
- Performance isn't perfect: REST instead of Kafka's own protocol. Although deploying multiple proxies may help a bit. I would not use this setting for high volume traffic. For messages with low message volume this may be good.
So, if you can live with the above problems, try Kafka Rest Proxy.