I faced the same problem. Since the new Zookeeper uses "Dynamic Reconfiguration", it is not that complicated, I think, to accomplish this. Just specify the ports (hpst:quorum:leaderelection;client
, host
defauts to 0.0.0.0
) in the ZOO_SERVERS
list. For the admin servers, one has to specify it per container--but that's optional.
ZOO_SERVERS="server.1=:2888:3888;2181 \
server.2=:2889:3889;2182 \
server.3=:2890:3890;2183"
podman pod create -n zkensemble -p 8080-8082,2181-2183
podman run --pod zkensemble --name zk1 \
-e ZOO_MY_ID=1 \
-e ZOO_SERVERS=$ZOO_SERVERS \
-d zookeeper
podman run --pod zkensemble --name zk2 \
-e ZOO_MY_ID=2 \
-e ZOO_SERVERS=$ZOO_SERVERS \
-e JVMFLAGS="-Dzookeeper.admin.serverPort=8081" \
-d zookeeper
podman run --pod zkensemble --name zk3 \
-e ZOO_MY_ID=3 \
-e ZOO_SERVERS=$ZOO_SERVERS \
-e JVMFLAGS="-Dzookeeper.admin.serverPort=8082" \
-d zookeeper
Of course, if you don't want the net
to be shared, there is also a solution, now complicated: all ports need to be exposed, including those for zookeeper interconnections and leader elections. However, this time all servers can stared with 8080 for the adminserver. We only need to map 8080 to different ports on the host.
IP=$(hostname -I | awk '{print $1}')
ZOO_SERVERS_1="server.1=:2888:3888;2181 \
server.2=$IP:2889:3889;2182 \
server.3=$IP:2890:3890;2183"
ZOO_SERVERS_2="server.1=$IP:2888:3888;2181 \
server.2=:2889:3889;2182 \
server.3=$IP:2890:3890;2183"
ZOO_SERVERS_3="server.1=$IP:2888:3888;2181 \
server.2=$IP:2889:3889;2182 \
server.3=:2890:3890;2183"
podman pod create -n zkensemble --share pid,ipc,uts
podman run --pod zkensemble --name zk1 \
-e ZOO_MY_ID=1 \
-e ZOO_SERVERS=$ZOO_SERVERS_1 \
-p 2181:2181,2888:2888,3888:3888,8080:8080 \
-d zookeeper
podman run --pod zkensemble --name zk2 \
-e ZOO_MY_ID=2 \
-e ZOO_SERVERS=$ZOO_SERVERS_2 \
-p 2182:2182,2889:2889,3889:3889,8081:8080 \
-d zookeeper
podman run --pod zkensemble --name zk3 \
-e ZOO_MY_ID=3 \
-e ZOO_SERVERS=$ZOO_SERVERS_3 \
-p 2183:2183,2890:2890,3890:3890,8082:8080 \
-d zookeeper