diff --git a/jkube-java-11.yaml b/jkube-java-11.yaml index 0da8a1b..ad3ee87 100644 --- a/jkube-java-11.yaml +++ b/jkube-java-11.yaml @@ -46,7 +46,7 @@ modules: - name: jboss.container.java.s2i.bash - name: jboss.container.java.run.bash - name: jboss.container.jolokia - version: jkube-2.0.0 + version: jkube-2.1.2 - name: jboss.container.prometheus version: jkube-0.20.0 - name: jboss.container.util.logging.bash diff --git a/jkube-java-17.yaml b/jkube-java-17.yaml index 1f23b83..8222fd4 100644 --- a/jkube-java-17.yaml +++ b/jkube-java-17.yaml @@ -50,7 +50,7 @@ modules: - name: jboss.container.java.s2i.bash - name: jboss.container.java.run.bash - name: jboss.container.jolokia - version: jkube-2.0.0 + version: jkube-2.1.2 - name: jboss.container.prometheus version: jkube-0.20.0 - name: jboss.container.util.logging.bash diff --git a/jkube-java.yaml b/jkube-java.yaml index 8153c25..1dff2b7 100644 --- a/jkube-java.yaml +++ b/jkube-java.yaml @@ -48,7 +48,7 @@ modules: - name: org.eclipse.jkube.s2i.bash version: 1.0.0 - name: org.eclipse.jkube.jolokia - version: 2.0.0 + version: 2.1.2 - name: jboss.container.util.logging.bash # Removes any other Java JDK that might have been downloaded by other packages (run last) - name: org.eclipse.jkube.jvm.singleton-jdk diff --git a/modules/jboss.container.jolokia/jkube-2.1.2/artifacts/opt/jboss/container/jolokia/jolokia-opts b/modules/jboss.container.jolokia/jkube-2.1.2/artifacts/opt/jboss/container/jolokia/jolokia-opts new file mode 100644 index 0000000..f0a3e12 --- /dev/null +++ b/modules/jboss.container.jolokia/jkube-2.1.2/artifacts/opt/jboss/container/jolokia/jolokia-opts @@ -0,0 +1,92 @@ +#!/bin/sh + +# Check whether a given config is contained in AB_JOLOKIA_OPTS +is_in_jolokia_opts() { + local prop=$1 + if [ -n "${AB_JOLOKIA_OPTS}" ] && [ x"${AB_JOLOKIA_OPTS}" != x"${AB_JOLOKIA_OPTS/${prop}/}" ]; then + echo "yes" + else + echo "no" + fi +} + +get_jolokia_properties() { + + echo "host=${AB_JOLOKIA_HOST:-*}" + echo "port=${AB_JOLOKIA_PORT:-8778}" + echo "discoveryEnabled=${AB_JOLOKIA_DISCOVERY_ENABLED:=false}" + + if [ -n "$AB_JOLOKIA_PASSWORD" ]; then + echo "user=${AB_JOLOKIA_USER:-jolokia}" + echo "password=${AB_JOLOKIA_PASSWORD}" + fi + if [ -n "$AB_JOLOKIA_HTTPS" ]; then + echo "protocol=https" + use_https=1 + fi + + # Integration with OpenShift client cert auth is enabled + # by default if not explicitly turned off by setting to 'false' + if [ "x${AB_JOLOKIA_AUTH_OPENSHIFT}" != "xfalse" ] && [ -f "/var/run/secrets/kubernetes.io/serviceaccount/ca.crt" ]; then + echo "useSslClientAuthentication=true" + echo "extraClientCheck=true" + + if [ -z ${use_https+x} ]; then + echo "protocol=https" + fi + if [ $(is_in_jolokia_opts "caCert") != "yes" ]; then + echo "caCert=/var/run/secrets/kubernetes.io/serviceaccount/ca.crt" + fi + + if [ $(is_in_jolokia_opts "clientPrincipal") != "yes" ]; then + if [ x"${AB_JOLOKIA_AUTH_OPENSHIFT}" != x"${AB_JOLOKIA_AUTH_OPENSHIFT/=/}" ]; then + # Supposed to contain a principal name to check + echo "clientPrincipal=`echo ${AB_JOLOKIA_AUTH_OPENSHIFT} | sed -e 's/ /\\\\ /g'`" + else + echo "clientPrincipal=cn=system:master-proxy" + fi + fi + fi + + # Add extra opts + if [ -n "${AB_JOLOKIA_OPTS}" ]; then + echo "${AB_JOLOKIA_OPTS}" | tr "," "\n" + fi + +} + +write_jolokia_properties() { + local jolokia_property_file="$1" + + # Setup Jolokia to accept basic auth, using a randomly generated password that is stored + # in the container in the ${DEPLOYMENTS_DIR}/jolokia.pw file. + if [ "$AB_JOLOKIA_PASSWORD_RANDOM" == "true" ]; then + pw_file="${JBOSS_CONTAINER_JOLOKIA_MODULE}/etc/jolokia.pw" + if [ -f "${pw_file}" ] ; then + AB_JOLOKIA_PASSWORD=`cat "${pw_file}"` + else + AB_JOLOKIA_PASSWORD=`tr -cd '[:alnum:]' < /dev/urandom | fold -w30 | head -n1` + touch "${pw_file}" + chmod 660 "${pw_file}" + cat > "${pw_file}" < "${jolokia_property_file}" < "${pw_file}" < "${jolokia_property_file}" <