Whatever happens in this blog-post only happens on my local developer laptop. And I strongly believe, that with regards to Oracle technologies this is absolutely covered by the so called OTN Free Developer License Agreement and the Oracle Binary Code License Agreement for Java SE.
I'm dead sure, that a production environment needs a bunch of licenses. But I'm not a specialist. So, don't ask me. If you want to use RHEL 7, please learn about the Red Hat Subscriptions.
Ok, WebLogic - Where's Your Image?
Not there. I assume for licensing reasons. But, Bruno did a great job in pushing relevant Dockerfiles and scripts to the official Oracle GitHub account. So. the first step in running WebLogic on Kubernetes is to actually build a docker image with it. Go,
and navigate to the OracleWebLogic folder. In fact, you can delete everything else beside this one. First step is to download the WebLogic ZIP installer and the correct JDK to be used.
git clone https://github.com/oracle/docker
Go to the Oracle Website, accept the OTN License (if you feel like it) and download the platform independent ZIP installer (wls1213_dev_update2.zip).
Now browse to the JDK download website, do the same license thing and download the 8u51 JDK as rpm (jdk-8u51-linux-x64.rpm). Place both into the OracleWebLogic\dockerfiles\126.96.36.199 folder. If you're running on a unix like OS yourself, feel free to check back with the official documentation and use the provided scripts. This didn't work for me on Windows, so you get a step-by-step walk-through. Go and rename the Dockerfile.developer to Dockerfile and delete all the other ones.
Now you open the Dockerfile and change a couple of things. Base it on RHEL 7:
mv Dockerfile.developer Dockerfile rm Dockerfile.*
And comment out the other base, that's in there ... And because, we want to run a decently patched and available Java version, we're going to change the environment variable accordingly
Time to build our image. And before you start, let's reuse the fabric8 vagrant installer, that I've been using for the last two blog-posts already. So, bring your vagrant instance with OpenShift up first. Now it's time to build the WebLogic image. Sit back and relax, because this is going to take a couple of more minutes. Do have some housekeeping to do? This might be the right time!
ENV JAVA_RPM jdk-8u51-linux-x64.rpm
Done? Check if everything is where we expect it to be: (docker images)
docker build --force-rm=true --tag="vagrant.f8:5000/oracle/weblogic:12.1.3-dev" .
Because this image only contains the server binaries, we now need to build an image which has a configured WLS domain in it. Thankfully, there are some more scripts in samples\12c-domain folder. So, go check, if the Dockerfile and all scripts in container-scripts have the correct UNIX line-ending. Sometimes, Git can mess them up, if you're on Windows. And if you're already there, make sure to change some ports according to your needs. I had to change the admin port to 8011 (do this in the Dockerfile and add-machine.py script. Another thing, we want to do is, to run the instance in development mode. This allows us to just copy our Java EE app into the ./autodeployment folder and have it deployed, when started. You can just changing the attribute in the following line from prod to dev:
vagrant.f8:5000/oracle/weblogic 12.1.3-dev 68f1ea788bba About a minute ago 2.05 GB
Now, you're ready to go ahead with building the development domain image:
And, after another couple of cups of coffee, we're ready to check if this image made it into our repository (docker images)
docker build --force-rm=true --tag="vagrant.f8:5000/myfear/weblogic:12.1.3-dev"
Before going any further, make sure to give it a shot and see, if the Weblogic instance comes up.
vagrant.f8:5000/myfear/weblogic 12.1.3-dev 77a3ec07d176 9 minutes ago 2.052 GB
If that worked, you're ready to build your third image today. Which will contain your application.
docker run -it myfear/weblogic:12.1.3-dev
NetBeans And Fabric8 - Take WebLogic Into Greek Heaven
Start NetBeans and create a nice, simple and lean Java EE 6 project from a maven archetype of your choice. Add all the fabric8 and docker-maven plugin dependencies to it, like I've shown you before in the first blog post of the series. Let's tweak the properties to our needs and just name the image: myfear/weblogic-test:latest. Most importantly, you have to map the container port to the Kubernetes service correctly:
Don't forget to use Java EE 6 as dependency, and change both user and deployment base in the docker-maven plugin to:
<!-- Kubernetes Service Port // Mapped via the HARouter--> <fabric8.service.port>9050</fabric8.service.port> <!-- The exposed container port --> <fabric8.service.containerPort>8011</fabric8.service.containerPort> <!-- because, I'm working with the remote registry here, base it on the remote image --> <docker.from>vagrant.f8:5000/myfear/weblogic:12.1.3-dev</docker.from> <!-- Just cosmetics, changing the container label --> <fabric8.label.container>weblogic</fabric8.label.container>
Time to build the third and last docker image:
And if that finished correctly, we're going to deploy everything to OpenShift with the Fabric8 tooling:
mvn clean install docker:build
And don't forget to add the host-name mapping to your hosts file.
mvn fabric8:json fabric8:apply
A request to http://myfear-weblogic-test.vagrant.f8/sample shows the application after you waited a couple of minutes (at least, I had to; Looks like my laptop wasn't quick enough.).
Some Further Remarks
This isn't exactly production ready. WLS knows managed servers and node managers and there are a bunch of ports for external communication, that need to be opened. This basically did nothing more than to deploy a teensy application onto the AdminServer. There are a couple of whitepapers and further ideas about how to tweak the domain scripts to fit your needs. I didn't want to do that for obvious reasons. So, consider this a proof of concept.