Build a multi node Kafka cluster on docker swarm -
i found docker image kafka
https://hub.docker.com/r/spotify/kafka/
and can create docker container using command documented in link
docker run -p 2181:2181 -p 9092:9092 --env advertised_host=`boot2docker ip` --env advertised_port=9092 spotify/kafka
this good. want configure "multiple" node kafka cluster running on docker swarm.
how can that?
i have been trying docker 1.12 using docker swarm mode
create nodes
docker-machine create -d virtualbox master docker-machine create -d virtualbox slave master_config=$(docker-machine config master | tr -d '\"') slave_config=$(docker-machine config slave | tr -d '\"') master_ip=$(docker-machine ip master) docker $master_config swarm init --advertise-addr $master_ip --listen-addr $master_ip:2377 worker_token=$(docker $master_config swarm join-token worker -q) docker $slave_config swarm join --token $worker_token $master_ip:2377 eval $(docker-machine env master)
create zookeeper service
docker service create --name zookeeper \ --constraint 'node.role == manager' \ -p 2181:2181 \ wurstmeister/zookeeper
create kafka service
docker service create --name kafka \ --mode global \ -e 'kafka_port=9092' \ -e 'kafka_advertised_port=9092' \ -e 'kafka_listeners=plaintext://0.0.0.0:9092' \ -e 'kafka_zookeeper_connect=tasks.zookeeper:2181' \ -e "hostname_command=ip r | awk '{ ip[\$3] = \$nf } end { print ( ip[\"eth0\"] ) }'" \ --publish '9092:9092' \ wurstmeister/kafka
though reason work within ingress or user defined overlay network , connection break kafka if try , connect through 1 of guest machines.
changing advertised ip doesn't make things better...
docker service create --name kafka \ --mode global \ -e 'kafka_port=9092' \ -e 'kafka_advertised_port=9092' \ -e 'kafka_listeners=plaintext://0.0.0.0:9092' \ -e 'kafka_zookeeper_connect=tasks.zookeeper:2181' \ -e "hostname_command=curl 192.168.99.1:5000" \ --publish '9092:9092' \ wurstmeister/kafka
i think new mesh networking , load balancing in docker might interfering kafka connection how....
to host container have flask app running locally curl
from flask import flask flask import request app = flask(__name__) @app.route('/') def hello_world(): return request.remote_addr
Comments
Post a Comment