multiple app nodes how to expose jmx in kubernetes?

前端 未结 4 811
醉话见心
醉话见心 2021-01-29 23:21
  1. In kubernetes I can expose services with service. This is fine.
  2. Lets say I have 1 web instance and 10 java server instances.
  3. I
4条回答
  •  时光取名叫无心
    2021-01-29 23:25

    Adding to https://stackoverflow.com/a/39927197/1387184, I wanted to monitor all instances of the same pod at once, since we are hardcoding the port as 1099, it was difficult as I can do only one portforward to one pod with that port.

    I used Shell Script to dynamically assign pod when running the docker

    Dockerfile CMD /run.sh

    run.sh

    JMX_PORT=$(((RANDOM % 20)+1099))

    echo "Running JMX on Port $JMX_PORT"

    java ``eval echo $JAVA_OPTS`` ...

    deployment.yml env: - name: JAVA_OPTS value: "-Xms256m -Xmx6144m -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.port=$JMX_PORT -Dcom.sun.management.jmxremote.rmi.port=$JMX_PORT -Djava.rmi.server.hostname=127.0.0.1"

    the eval will evaluate the JMX_PORT to bash value, each pod when starts will likely to get different pod. I

提交回复
热议问题