OneCricketeer / apache-kafka-connect-docker

[KAFKA-9774] Un-official Docker Image for Apache Kafka Connect
https://issues.apache.org/jira/browse/KAFKA-9774
Apache License 2.0
34 stars 15 forks source link

How to conditionally add jvm flags for entrypoint? #43

Closed sappusaketh closed 5 months ago

sappusaketh commented 5 months ago

Hello, This might be more of a discussion. I want to enable jmx metrics if I set env var JMX_PORT during docker run. So I m using your image as base and installing confluent connector jars and then doing docker run. I m new to jib wondering if I can set jvm flags conditionally somehow. At present I added jvm flag directly to your pom.xml and built base image but trying to see If I can make this optional somehow . Or else this has to be specified using maven profiles and I have to build two base images one with jmx and other without jmx? One option I was thinking is adding entrypoint in my child docker image where I m installing confluent connector jars but wondering if this can be done somehow in pom.xml. Thanks for everything you do

OneCricketeer commented 5 months ago

The Kafka shell scripts that wire that variable into the java command are not available, so adding that specific env-var will not do anything.

At runtime, you can add JAVA_TOOL_OPTIONS to mimic what the native Kafka start script would add

JAVA_TOOL_OPTIONS=' -Dcom.sun.management.jmxremote.port=<port> -Dcom.sun.management.jmxremote.rmi.port=<port>'
sappusaketh commented 5 months ago

thanks that worked

sappusaketh commented 5 months ago

so you recommend adding jmx_prometheus_javaagent-0.20.0.jar to same image where we are downloading confluent jars looking to to see if we can include this jar optionally somehow in your base image

Edit: After reading my comment I think it doesnt make sense to add jar optionally if we want to use one base image I think I will add this along with confluent jars

thank you