cp-docker-images icon indicating copy to clipboard operation
cp-docker-images copied to clipboard

Zookeeper image doesn't support disabling Admin Server using environment vars.

Open amitga opened this issue 4 years ago • 9 comments

Hi. The Admin Server is enabled by default in the cp-zookeeper image version 5.4.0. This means that zookeeper spawns up a web server on port 8080 by default. You can disable it, or change the port using zookeepers conf file, but this is not possible using environment variables. It seems that only some of zookeeper's properties are configurable using environment variables, as you can see in the zookeeper.properties.template file.

In the official Apache Zookeeper docker image, you can disable it using the ZOO_ADMINSERVER_ENABLED env variable.

I think that the admin server parameters should be added to the template accordingly:

AdminServer configuration New in 3.5.0: The following options are used to configure the AdminServer.

admin.enableServer (Java system property: zookeeper.admin.enableServer)

Set to "false" to disable the AdminServer. By default the AdminServer is enabled.

admin.serverPort (Java system property: zookeeper.admin.serverPort)

The port the embedded Jetty server listens on. Defaults to 8080.

admin.commandURL (Java system property: zookeeper.admin.commandURL)

The URL for listing and issuing commands relative to the root URL. Defaults to "/commands".

Taken from here

amitga avatar Mar 01 '20 08:03 amitga

Hello @amitga-rnd

Please use KAFKA_OPTS variable for extra Java system properties. Refer #827

OneCricketeer avatar Mar 13 '20 01:03 OneCricketeer

Hi @OneCricketeer ,

Could you please give more hints to complete the KAFKA_OPTS with disable adminserver? I want to disable adminserver but indeed I cannot use -e to disable it. I guess I have to use KAFKA_OPTS like what you have said, but after trying I still can't success.

Thank you!

Sean77509 avatar Jun 18 '20 03:06 Sean77509

I use the cp-zookeeper:5.5.0 and I have to start more than 1 container in 1 OS. when I start 2nd zookeeper container I always get the "address already in use" error.

Sean77509 avatar Jun 18 '20 03:06 Sean77509

I have tried use docker run..... -e KAFKA_OPTS:"zookeeper.admin.enableServer=false"
or -e KAFKA_OPTS:"-Dzookeeper.admin.enableServer=false" \

but it doesn't work. Thank!

Sean77509 avatar Jun 18 '20 03:06 Sean77509

You should be able to use "official Apache Zookeeper docker image" fine... You don't need cp-zookeeper... It doesn't add anything that Apache doesn't already have

OneCricketeer avatar Jun 18 '20 04:06 OneCricketeer

But according to the docs, that property is allow to be set with Java system properties

https://zookeeper.apache.org/doc/r3.6.1/zookeeperAdmin.html#sc_adminserver_config

However, I am not certain Confluent uses Zookeeper 3.6.x yet

OneCricketeer avatar Jun 18 '20 04:06 OneCricketeer

I'm not sure what you mean by "doesn't work"... What did you try to do to debug? It seems "to work" to me... As in, the property is there

docker run --rm -e KAFKA_OPTS='-Dzookeeper.admin.enableServer=false' -e ZOOKEEPER_CLIENT_PORT=2181 confluentinc/cp-zookeeper:5.5.0

$ docker ps
CONTAINER ID        IMAGE                             COMMAND                  CREATED              STATUS              PORTS                          NAMES
b3f462396507        confluentinc/cp-zookeeper:5.5.0   "/etc/confluent/dock…"   

$ docker exec -ti b3f bash

root@b3f462396507:/# ps -ef | grep java
root         1     0  1 04:27 ?        00:00:01 java -Xmx512M -Xms512M -server -XX:+UseG1GC ... -Dzookeeper.admin.enableServer=false org.apache.zookeeper.server.quorum.QuorumPeerMain /etc/kafka/zookeeper.properties
root       127   119  0 04:29 pts/0    00:00:00 grep java
root@b3f462396507:/#

OneCricketeer avatar Jun 18 '20 04:06 OneCricketeer

when I start 2nd zookeeper container I always get the "address already in use

Why? Sounds like a port issue, not the admin server within the container, but rather the allocated ports on your host

OneCricketeer avatar Jun 18 '20 04:06 OneCricketeer

Hi @OneCricketeer, Thank you for replying and I've solved this issue through the correct KAFKA_OPTS usage you gave me. I wrote it in wrong way so it did not work before. Thanks a lot!

Sean77509 avatar Jun 18 '20 06:06 Sean77509