Skip to content

Commit

Permalink
Merge pull request #428 from jshaughn/hawkular-1275
Browse files Browse the repository at this point in the history
Hawkular 1275
  • Loading branch information
jshaughn authored Dec 18, 2017
2 parents ce37084 + 2a47608 commit a7a88fc
Show file tree
Hide file tree
Showing 186 changed files with 6,194 additions and 17,822 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,5 @@ branches:
only:
- master
- /^(\d+\.){2}(\d+){1}(\.[a-zA-Z\d]+)?$/
- hawkular-1259
- hawkular-1275

2 changes: 1 addition & 1 deletion README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ You attach the Hawkular Java Agent to your own application, so running your appl
If you want to test the Hawkular Java Agent, you can run it standalone and just point it to a remote Java application to manage (you do this by addinga remote-dmr or remote-jmx managed server definition to its configuration file). You can run it like this:

```
java -Dhawkular.rest.user=jdoe -Dhawkular.rest.password=password -Dhawkular.rest.host=http://localhost:8080 -jar hawkular-javaagent/target/hawkular-javaagent-*-shaded.jar config=hawkular-javaagent-wildfly-feature-pack/src/main/resources/featurepack/content/standalone/configuration/hawkular-javaagent-config.yaml
java -Dhawkular.rest.user=jdoe -Dhawkular.rest.password=password -Dhawkular.rest.url=http://localhost:8080 -jar hawkular-javaagent/target/hawkular-javaagent-*-shaded.jar config=hawkular-javaagent-wildfly-feature-pack/src/main/resources/featurepack/content/standalone/configuration/hawkular-javaagent-config.yaml
```
28 changes: 10 additions & 18 deletions docker-dist/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,33 +20,25 @@ FROM jboss/wildfly:11.0.0.Final
MAINTAINER Hawkular project <[email protected]>

# ADD test-simple.war /opt/jboss/wildfly/standalone/deployments/
COPY target/hawkular-javaagent.jar $JBOSS_HOME/bin/
COPY target/hawkular-javaagent-config.yaml /opt/hawkular/configuration/

ADD src/main/resources/run_hawkular_javaagent.sh /opt/hawkular/bin/run_hawkular_agent.sh
COPY target/hawkular $JBOSS_HOME/
COPY src/main/resources/run_hawkular_javaagent.sh /opt/hawkular/bin/run_hawkular_agent.sh

ENV HAWKULAR_URL=http://hawkular:8080 \
HAWKULAR_AGENT_USER=jdoe \
HAWKULAR_AGENT_PASSWORD=password \
HAWKULAR_IMMUTABLE=true \
HAWKULAR_MODE=standalone
HAWKULAR_USER=jdoe \
HAWKULAR_PASSWORD=password \
HAWKULAR_AGENT_IMMUTABLE=true \
HAWKULAR_AGENT_METRICS_PORT=9779 \
HAWKULAR_AGENT_MODE=standalone

EXPOSE 8080 9090
EXPOSE 8080 9090 9779

USER root
RUN printf 'JAVA_OPTS="$JAVA_OPTS' >> $JBOSS_HOME/bin/standalone.conf
RUN printf 'HOST_CONTROLLER_JAVA_OPTS="$HOST_CONTROLLER_JAVA_OPTS' >> $JBOSS_HOME/bin/domain.conf
RUN printf ' -Djboss.modules.system.pkgs=org.jboss.byteman,org.jboss.logmanager -Djava.util.logging.manager=org.jboss.logmanager.LogManager -javaagent:$JBOSS_HOME/bin/hawkular-javaagent.jar=config=/opt/hawkular/configuration/hawkular-javaagent-config.yaml,delay=10' \
| tee -a $JBOSS_HOME/bin/standalone.conf $JBOSS_HOME/bin/domain.conf > /dev/null
RUN printf ' -Djboss.host.server-excluded-properties=jboss.modules.system.pkgs,java.util.logging.manager' >> $JBOSS_HOME/bin/domain.conf
RUN printf ' -Dhawkular.rest.host=${HAWKULAR_URL} -Dhawkular.agent.immutable=${HAWKULAR_IMMUTABLE} -Dhawkular.agent.in-container=${HAWKULAR_IMMUTABLE}"\n' \
| tee -a $JBOSS_HOME/bin/standalone.conf $JBOSS_HOME/bin/domain.conf > /dev/null


RUN yum install --quiet -y openssl && \
rm -rf /var/cache/yum && \
chown -RH jboss:0 $JBOSS_HOME/standalone $JAVA_HOME/jre/lib/security/cacerts /opt/hawkular && \
chmod -R ug+rw $JBOSS_HOME/standalone $JAVA_HOME/jre/lib/security/cacerts /opt/hawkular && \
chown -RH jboss:0 $JBOSS_HOME $JAVA_HOME/jre/lib/security/cacerts /opt/hawkular && \
chmod -R ug+rw $JBOSS_HOME $JAVA_HOME/jre/lib/security/cacerts /opt/hawkular && \
chmod -R a+rw /opt/hawkular/ && \
chmod -R a+x $JBOSS_HOME

Expand Down
6 changes: 3 additions & 3 deletions docker-dist/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ build.sh devel hawkular/wildfly-javaagent

You will typically need three pieces of information when connecting to a remote Hawkular Services server: the URL for the Hawkular Services server, a username and a password.

This information can be passed to the docker image via environment properties: 'HAWKULAR_URL', 'HAWKULAR_AGENT_USER', 'HAWKULAR_AGENT_PASSWORD'
This information can be passed to the docker image via environment properties: 'HAWKULAR_URL', 'HAWKULAR_USER', 'HAWKULAR_PASSWORD'

By default, the docker image will start a Wildfly in standalone mode. You can control if you want to start a Wildfly
in domain mode by setting the environment property 'HAWKULAR_MODE' to 'domain'.
in domain mode by setting the environment property 'HAWKULAR_AGENT_MODE' to 'domain'.

NOTE: For security reasons, it is recommend to only pass secret information such as usernames and passwords via an property file and not as normal parameters.

Expand All @@ -49,7 +49,7 @@ NOTE: the following instructions are listed using the OpenShift 'oc' command. If

Like in the Docker example, we will need to pass the Hawkular Services URL, username and password to our pod. Unlike in the Docker example, for our pod will will pass this information as a secret.

The process for this is similar to the Docker example. We will create a file which will contain properties 'HAWKULAR_URL', 'HAWKULAR_AGENT_USER', and 'HAWKULAR_AGENT_PASSWORD'.
The process for this is similar to the Docker example. We will create a file which will contain properties 'HAWKULAR_URL', 'HAWKULAR_USER', and 'HAWKULAR_PASSWORD'.

Please see the 'example-env-file' for an example.

Expand Down
4 changes: 2 additions & 2 deletions docker-dist/example-env-file
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
HAWKULAR_URL=http://hawkular.example.com:8080
HAWKULAR_AGENT_USER=jdoe
HAWKULAR_AGENT_PASSWORD=password
HAWKULAR_USER=jdoe
HAWKULAR_PASSWORD=password
8 changes: 4 additions & 4 deletions docker-dist/hawkular-javaagent-example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,16 @@ spec:
secretKeyRef:
name: hawkular-javaagent-example
key: HAWKULAR_URL
- name: HAWKULAR_AGENT_USER
- name: HAWKULAR_USER
valueFrom:
secretKeyRef:
name: hawkular-javaagent-example
key: HAWKULAR_AGENT_USER
- name: HAWKULAR_AGENT_PASSWORD
key: HAWKULAR_USER
- name: HAWKULAR_PASSWORD
valueFrom:
secretKeyRef:
name: hawkular-javaagent-example
key: HAWKULAR_AGENT_PASSWORD
key: HAWKULAR_PASSWORD
volumeMounts:
- name: secrets
mountPath: /client-secrets
Expand Down
22 changes: 14 additions & 8 deletions docker-dist/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,6 @@
<groupId>com.mycila</groupId>
<artifactId>license-maven-plugin</artifactId>
<configuration>
<mapping>
<Dockerfile-wf-agent>SCRIPT_STYLE</Dockerfile-wf-agent>
<Dockerfile-wf-agent-domain>SCRIPT_STYLE</Dockerfile-wf-agent-domain>
</mapping>

<excludes>
<exclude>.dockerignore</exclude>
<exclude>**/*.war</exclude>
Expand Down Expand Up @@ -105,7 +100,6 @@
<artifactId>hawkular-javaagent-wildfly-dist</artifactId>
<type>zip</type>
<outputDirectory>${project.build.directory}</outputDirectory>
<includes>**/hawkular-javaagent-config.yaml</includes>
</artifactItem>
</artifactItems>
</configuration>
Expand All @@ -121,8 +115,20 @@
<phase>generate-resources</phase>
<configuration>
<target>
<move file="${project.build.directory}/hawkular-javaagent-${project.version}-shaded.jar" tofile="${project.build.directory}/hawkular-javaagent.jar" />
<move file="${project.build.directory}/hawkular-javaagent-wildfly-dist-${project.version}/standalone/configuration/hawkular-javaagent-config.yaml" tofile="${project.build.directory}/hawkular-javaagent-config.yaml" />
<!-- Global -->
<move file="${project.build.directory}/hawkular-javaagent-${project.version}-shaded.jar" tofile="${project.build.directory}/hawkular/bin/hawkular-javaagent.jar" />
<move file="${project.build.directory}/hawkular-javaagent-wildfly-dist-${project.version}/bin/start-with-hawkular.sh" tofile="${project.build.directory}/hawkular/bin/start-with-hawkular.sh" />

<!-- Standalone -->
<move file="${project.build.directory}/hawkular-javaagent-wildfly-dist-${project.version}/standalone/configuration/hawkular-javaagent-config.yaml" tofile="${project.build.directory}/hawkular/standalone/configuration/hawkular-javaagent-config.yaml" />
<move file="${project.build.directory}/hawkular-javaagent-wildfly-dist-${project.version}/bin/standalone.conf" tofile="${project.build.directory}/hawkular/bin/standalone.conf" />

<!-- Domain -->
<move file="${project.build.directory}/hawkular-javaagent-wildfly-dist-${project.version}/domain/configuration/hawkular-javaagent-config-domain.yaml" tofile="${project.build.directory}/hawkular/domain/configuration/hawkular-javaagent-config-domain.yaml" />
<move file="${project.build.directory}/hawkular-javaagent-wildfly-dist-${project.version}/domain/configuration/hawkular-javaagent-config-metrics-only.yaml" tofile="${project.build.directory}/hawkular/domain/configuration/hawkular-javaagent-config-metrics-only.yaml" />
<move file="${project.build.directory}/hawkular-javaagent-wildfly-dist-${project.version}/domain/configuration/host-hawkular.xml" tofile="${project.build.directory}/hawkular/domain/configuration/host-hawkular.xml" />
<move file="${project.build.directory}/hawkular-javaagent-wildfly-dist-${project.version}/bin/domain.conf" tofile="${project.build.directory}/hawkular/bin/domain.conf" />

</target>
</configuration>
<goals>
Expand Down
15 changes: 8 additions & 7 deletions docker-dist/src/main/resources/run_hawkular_javaagent.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,19 @@ import_hawkular_services_public_key() {
}

run_hawkular_agent() {
exec ${JBOSS_HOME}/bin/${HAWKULAR_MODE}.sh -b 0.0.0.0
local START_WITH_HAWKULAR_PARAMS="-s ${HAWKULAR_URL}"
if [[ "${HAWKULAR_AGENT_MODE}" == "domain" ]]; then
START_WITH_HAWKULAR_PARAMS="$START_WITH_HAWKULAR_PARAMS -d"
fi
${JBOSS_HOME}/bin/start-with-hawkular.sh ${START_WITH_HAWKULAR_PARAMS} "$@"
}

main() {
HAWKULAR_MODE=`echo ${HAWKULAR_MODE} | tr '[:upper:]' '[:lower:]'`
if [[ "${HAWKULAR_MODE}" != "standalone" ]] && [[ "${HAWKULAR_MODE}" != "domain" ]]; then
echo 'HAWKULAR_MODE must be set to "standalone" or "domain", found:' ${HAWKULAR_MODE}
HAWKULAR_AGENT_MODE=`echo ${HAWKULAR_AGENT_MODE} | tr '[:upper:]' '[:lower:]'`
if [[ "${HAWKULAR_AGENT_MODE}" != "standalone" ]] && [[ "${HAWKULAR_AGENT_MODE}" != "domain" ]]; then
echo 'HAWKULAR_AGENT_MODE must be set to "standalone" or "domain", found:' ${HAWKULAR_AGENT_MODE}
exit
fi
if [[ "${HAWKULAR_MODE}" == "domain" ]]; then
sed -i "s|- Standalone Environment|- Domain Environment|g" /opt/hawkular/configuration/hawkular-javaagent-config.yaml
fi
import_hawkular_services_public_key
run_hawkular_agent "$@"
}
Expand Down
Loading

0 comments on commit a7a88fc

Please sign in to comment.