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,
git clone https://github.com/oracle/docker
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.
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\188.8.131.52 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.
mv Dockerfile.developer Dockerfile
Now you open the Dockerfile and change a couple of things. Base it on RHEL 7:
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:
ENV JAVA_RPM jdk-8u51-linux-x64.rpm
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!
docker build --force-rm=true --tag="vagrant.f8:5000/oracle/weblogic:12.1.3-dev" .
Done? Check if everything is where we expect it to be: (docker images)
vagrant.f8:5000/oracle/weblogic 12.1.3-dev 68f1ea788bba About a minute ago 2.05 GB
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:
Now, you’re ready to go ahead with building the development domain image:
docker build --force-rm=true --tag="vagrant.f8:5000/myfear/weblogic:12.1.3-dev"
And, after another couple of cups of coffee, we’re ready to check if this image made it into our repository (docker images)
vagrant.f8:5000/myfear/weblogic 12.1.3-dev 77a3ec07d176 9 minutes ago 2.052 GB
Before going any further, make sure to give it a shot and see, if the Weblogic instance comes up.
docker run -it myfear/weblogic:12.1.3-dev
If that worked, you’re ready to build your third image today. Which will contain your application.
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:
<!-- Kubernetes Service Port // Mapped via the HARouter-->
<!-- The exposed container port -->
<!-- because, I'm working with the remote registry here, base it on the remote image -->
<!-- Just cosmetics, changing the container label -->
Don’t forget to use Java EE 6 as dependency, and change both user and deployment base in the docker-maven plugin to:
Time to build the third and last docker image:
mvn clean install docker:build
And if that finished correctly, we’re going to deploy everything to OpenShift with the Fabric8 tooling:
mvn fabric8:json fabric8:apply
And don’t forget to add the host-name mapping to your hosts file.
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.
|Reference:||WebLogic Server 12.1.3 on Kubernetes from our JCG partner Markus Eisele at the Enterprise Software Development with Java blog.|