JRebel with Red Hat OpenShift 3¶
JRebel remote server support is compatible with Red Hat OpenShift version 3. Openshift is built around Docker containers managed by Kubernetes.
This tutorial will walk you through installing JRebel as an Init Container in OpenShift. Init Containers are Docker images that are run before starting the application. As they can be mounted to the pod storage, it is a convenient way of downloading and unpacking tools like JRebel for use by the application. OpenShift provides interactive playgrounds which can be used to experiment with setups like installing JRebel.
JRebel for Cloud Tutorial¶
Install and configure JRebel on your local workstation.
1.1 Using Eclipse? Install JRebel for Eclipse and configure JRebel for Cloud in Eclipse.
1.2 Using IntelliJ IDEA? Install JRebel for IntelliJ IDEA and configure JRebel for Cloud in IntelliJ IDEA.
1.3 Using NetBeans? Install JRebel for NetBeans and configure JRebel for Cloud in NetBeans.
Set up the Openshift command-line tools or start a playground session.
Log in to your OpenShift server using
oc login
. In the playground session, the login command is displayed on the left and can be clicked on.Create a new OpenShift project:
$ oc new-project test
Choose a base image and provide an application.
5.1 The application must be configured to use JRebel remote server support. The built artifact must contain a
rebel-remote.xml
.5.2 The application should be available through a public Git repository.
5.3 For testing purposes we recommend forking a demo application such as spring-framework-petclinic and adding a
rebel-remote.xml
tosrc/main/resources
Create a new OpenShift application:
$ oc new-app openshift/wildfly-140-centos7~https://github.com/<user>/spring-framework-petclinic
Hint
Provide the actual Git repository URL. The URL has to point to the application.
7. Change the deployment.yml
configuration to contain the following elements. Some of these properties will need to be appended to existing elements.
If you are using the interactive playground, log in to the dashboard, select the project, select the created app under Applications > Deployments then on the right choose Actions > Edit YAML.
spec: template: spec: initContainers: - name: jrebel image: alpine imagePullPolicy: IfNotPresent command: - sh - '-c' - >- [ -d /jrebel/jrebel ] || (wget http://dl.zeroturnaround.com/jrebel-stable-nosetup.zip && unzip jrebel-stable-nosetup.zip -d /jrebel) volumeMounts: - mountPath: /jrebel name: jrebel volumes: - name: jrebel emptyDir: {} containers: - name: spring-framework-petclinic env: - name: JAVA_OPTS value: >- -agentpath:/jrebel/jrebel/lib/libjrebel64.so -Drebel.remoting_plugin=true volumeMounts: - mountPath: /jrebel name: jrebelHint
The deployment should restart after the configuration change. Verify from the Logs tab that the JRebel banner is present.
Create a route to expose the application to the web. This can be done with the command
oc expose svc/spring-framework-petclinic
Configure your project’s remote server application URL in the IDE to reflect the OpenShift application URL (you can find this from the OpenShift Overview page for the test project).
Press the Synchronize button in your IDE to upload any changes. Now simply refresh the application on the cloud platform and your changes should appear like clockwork! Success!
Note
When a pod is recreated, the JRebel Remote cache is cleared and the started application will revert to the deployed state. To avoid this, specify the
REBEL_BASE
environment variable and point it to a persistent storage volume.