Introduction:

Oracle WebLogic Server for OKE (called WLS for OKE in this document) is an offering in the Oracle Cloud Marketplace that simplifies running WebLogic Server applications on Kubernetes on Oracle Cloud.

Oracle WebLogic Server for OKE deploys Jenkins (called WLS for OKE Jenkins in this document) to a Kubernetes cluster with a set of pre-configured jobs (refer to this page for the list). These jobs leverage the Oracle WebLogic Kubernetes toolkit tools such as Oracle WebLogic Deploy Tooling (WDT), Oracle WebLogic Image Tool (WIT), and Oracle WebLogic Kubernetes operator to deploy applications, libraries, and resources on WebLogic domains, apply JDK and WebLogic Server patches, and update existing container images.

Given that many companies already have deployed continuous integration and continuous delivery (called CI/CD in this document) solutions with jobs defined to automate code integration and the delivery process, it is logical to integrate them with the Jenkins Pipeline included in Oracle WebLogic Server for OKE. This blog shows how to deploy an application from a development environment to a WebLogic cluster in WLS for OKE. Steps:

  • The application WAR file is built on the Developer’s host, after getting the source code from the GitHub workspace.
  • A script is executed  on the Developer’s host to launch the update_domain job on WLS for OKE Jenkins.
  • The update_domain job deploys the application WAR file on the WebLogic cluster. 

These steps can be run using any existing CI/CD solution of your choice to perform the software build, deploy, and release lifecycle automation. To demonstrate the script execution, another Jenkins instance is used (called Developer’s Jenkins in this document). This document will show you how to create a job in the Developer’s Jenkins to build an application checked into the GitHub workspace, and then trigger a WLS for OKE Jenkins update_domain job.  

Oracle WebLogic Server for OKE Application Deployment Workflow

Summary of steps discussed 

  1. Setup WebLogic server for OKE
  2. Create a WebLogic application
  3. Create a WLS for OKE Jenkins Pipeline job launcher script
  4. Setup a Developer’s CI/CD solution (Developer’s Jenkins)
  5. Create a job on Developer’s Jenkins  to execute WLS for OKE Jenkins Pipeline job launcher script created in Step 3.
  6. Execute the job on Developer’s Jenkins and review the console log

  7. Verify the deployed web application

1. Setup WebLogic server for OKE

  • Create a WebLogic Server for OKE stack (steps).
  • Connect to WLS for OKE Jenkins admin console (steps), and create the admin user and password.

Jenkins login

  • Go to scriptApproval under manage jenkins menu, and approve all listed scripts
    • Jenkins URL=http://<internal_lb_ip>/jenkins/scriptApproval/  
  • Run create_domain job on WLS for OKE Jenkins to create a WebLogic domain. Steps
    • Use a domain name of your choice. For example: Domain Name = “mydomain”
    • Jenkins URL=http://<internal_lb_ip>/jenkins/job/create domain/

create domain pipeline job

  • After the create domain job succeeds, verify the WebLogic console access for the domain (steps). 

 weblogic console

 

  • Create a token to enable remote trigger for the WLS for OKE Jenkins update_domain job. 
    • Jenkins URL: http://<internal_lb_ip>/jenkins/job/update%20domain/configure
    • On Jenkins Dashboard, click on “update_domain”, and click on “Configure”, Click on “Build Triggers”, Check “Trigger builds remotely”, in “Authentication Token” text box, enter “WLSOKE_TOKEN”

Jenkins Authentication Token

  • Note down the following information for the WLS for OKE stack. This information is required for executing the launcher script. 
    • bastion public ip
    • admin instance private ip
    • SSH private key file of the ssh key used for stack creation
    • WebLogic domain name
    • Token name for the update_domian job

2. Create a WebLogic application 

The sample application is already checked in the GitHub workspace (link). 

3. Create a WLS for OKE Jenkins Pipeline job launcher script

The script to launch WLS for OKE Jenkins Pipeline job includes the following steps. The script is already created and checked in the GitHub workspace (link).

  • Connect to WLS for OKE administration host over an ssh tunnel (steps)
  • Launch the update_domain job on WLS for OKE Jenkins by using the Jenkins REST API
  • Wait for the job completion, and report PASS/FAIL status

4. Setup a Developer’s CI/CD Solution (Developer’s Jenkins)

Any CI/CD solution of your choice can be used for the WebLogic application deployment automation on WLS for OKE. For this demonstration, Jenkins is set up to run at http://localhost:8080 on the Developer’s host. This is referred to as Developer’s Jenkins, which includes the Jenkins controller and agent, with access to the development environment. 

  • Jenkins controller requirements: Install git plugin – required to pull the WebLogic application and deployment script from the GitHub workspace.
  • Jenkins agent requirements:
    • Install mvn and JDK8  – required to build the WebLogic application. Install python3 – required to run the deployment script.
    • Include mvn, java and python3 in the PATH.
    • Allow SSH connection from Developer’s Jenkins agent to WLS for OKE administration host using the bastion host as a proxy (steps) – required to trigger WLS for OKE Jenkins Pipeline job. 

5. Create a job on the Developer’s Jenkins to execute WLS for OKE Jenkins Pipeline job launcher script created in Step 3

The following steps show how to create a new job named wlsoke_cicd in the Developer’s Jenkins. This job launches the update_domain job on WLS for OKE Jenkins Pipeline to deploy the application on the WebLogic cluster.

5.1  Create a new job:   http://localhost:8080/view/all/newJob

  • Enter an item name: wlsoke-cicd

  • Select Freestyle Project

  • Click on OK

external Jenkins new job

5.2 Configure the job: http://localhost:8080/job/wlsoke_cicd/configure

5.2.1  Add Source Code Management to the Job to pull source code from the GitHub repository which contains the source code for WLS web app and the deployment script.

Developer's Jenkins Source Code Management

5.2.2 Add Build Script: The job execution script is a one-liner, which simply calls the pre-created script launch-jenkins-update-domain-job.sh from the source repository.

Developer's Jenkins Build script

The Developer’s Jenkins job  calls the script launch-jenkins-update-domain-job.sh which executes the following steps:

  • Build the web app pulled from the GitHub repository
  • Copy over the webapp artifacts from the user’s desktop to WLS for OKE admin server for deployment 
  • Trigger update_domain job on WLS for OKE Jenkins
  • Monitor the job execution and report pass/fail status
  • Report the Webapp access URL for the deployed app if the update_domain job is successful

5.2.3. Add job parameters: Add the following parameters to wlsoke-cicd job. The values for these are available after the Step 1 – “Create a WebLogic Server for OKE stack” is completed. Update the following to match your environment. 

  • ADMIN_IP=”10.0.2.4″ 
  • SSH_PRIVATE_KEY_FILE=”~/.ssh/my_ssh_key” 
  • BASTION_IP=”x.y.z.188″ 
  • JENKINS_CREDS=”weblogic:<your_password>” 
  • JENKINS_JOB_NAME=”update%20domain”
  • JENKINS_JOB_TOKEN_NAME=”WLSOKE_TOKEN”
  • DOMAIN_NAME=mydomain

 external jenkins launcher job parameters

The source code for the wlsoke-cicd job is available (config.xml) for reference. 

6. Execute the job on the Developer’s Jenkins and review the console log

Started by user admin
Running as SYSTEM
Building in workspace /Users/**/hudson/workspace/wlsoke_cicd
:
 > git fetch --tags --force --progress -- https://github.com/**/wlscicd.git +refs/heads/*:refs/remotes/origin/* # timeout=10
:
+ bash /Users/**/hudson/workspace/wlsoke_cicd/src/launch-jenkins-update-domain-job.sh
:
+ mvn install
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=1024m; support was removed in 8.0
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] WDT Sample Webapp                                                  [pom]
[INFO] webapp                                                             [war]
[INFO] wls_deployment                                                     [pom]
[INFO]
[INFO] --------------------< com.wdtdemo.weblogic:wdtdemo >--------------------
[INFO] Building WDT Sample Webapp 1.0-SNAPSHOT                            [1/3]
[INFO] --------------------------------[ pom ]---------------------------------
:
[INFO] --- maven-war-plugin:2.2:war (default-war) @ webapp ---
[INFO] Packaging webapp
[INFO] Assembling webapp [webapp] in [/Users/**/hudson/workspace/wlsoke_cicd/src/wdtdemo/webapp/target/wdt-demo-web]
[INFO] Processing war project
[INFO] Copying webapp resources [/Users/**/hudson/workspace/wlsoke_cicd/src/wdtdemo/webapp/src/main/webapp]
[INFO] Webapp assembled in [55 msecs]
[INFO] Building war: /Users/**/hudson/workspace/wlsoke_cicd/src/wdtdemo/webapp/target/wdt-demo-web.war
[INFO] WEB-INF/web.xml already added, skipping
[INFO]
:
[INFO]
[INFO] ----------------< com.wdtdemo.weblogic:wls_deployment >-----------------
[INFO] Building wls_deployment 1.0-SNAPSHOT                               [3/3]
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- maven-assembly-plugin:2.2-beta-5:single (wdt_archive) @ wls_deployment ---
[INFO] Reading assembly descriptor: src/assembly/assemble.xml
[INFO] Building zip: /Users/**/hudson/workspace/wlsoke_cicd/src/wdtdemo/wls_deployment/target/wdt_archive.zip
:
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for WDT Sample Webapp 1.0-SNAPSHOT:
[INFO]
[INFO] WDT Sample Webapp .................................. SUCCESS [  0.329 s]
[INFO] webapp ............................................. SUCCESS [  1.205 s]
[INFO] wls_deployment ..................................... SUCCESS [  1.107 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  2.760 s
[INFO] Finished at: 2022-07-08T12:40:37-06:00
[INFO] ------------------------------------------------------------------------
:
OK: /Users/**/hudson/workspace/wlsoke_cicd/src/wdtdemo/wls_deployment/src/domain/models/model.10.yaml --> admin_vm:/u01/shared/model.yaml
OK: /Users/**/hudson/workspace/wlsoke_cicd/src/wdtdemo/wls_deployment/src/domain/models/model.10.properties --> admin_vm:/u01/shared/model.properties
OK: /Users/**/hudson/workspace/wlsoke_cicd/src/wdtdemo/wls_deployment/target/wdt_archive.zip --> admin_vm:/u01/shared/archive.zip
+ python3 /Users/**/hudson/workspace/wlsoke_cicd/src/launch-jenkins-job.py launch
ssh -o LogLevel=quiet -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i ~/.ssh/xperiment_rsa -o ProxyCommand="ssh -W %h:%p -i ~/.ssh/xperiment_rsa opc@129.153.192.188" opc@10.0.2.4 'curl --silent -X GET --user **:** -H Jenkins-Crumb:69c5ac67d436d18ceca2971dac4533faeebcc5e82b268e959f9bf0ce958732af "http://10.0.6.9/jenkins/job/update%20domain/buildWithParameters?token=WLSOKE_TOKEN&Domain_Name=hvdomain2&Archive_Source=Shared%20File%20System&Archive_File_Location=%2Fu01%2Fshared%2Farchive.zip&Domain_Model_Source=Shared%20File%20System&Model_File_Location=%2Fu01%2Fshared%2Fmodel.yaml&Variable_Source=Shared%20File%20System&Variable_File_Location=%2Fu01%2Fshared%2Fmodel.properties&Rollback_On_Failure=true"'
Started the job update%20domain
.
Jenkins CI/CD Job update%20domain Build 13 status: SUCCESS
+ exit_code=0
:
app_url via external lb: https://x.y.z.104/webapp
Finished: SUCCESS

7. Verify the deployed web application

 Deployed WebLogic application

Glossary

  1. CI/CD:  A development workflow based on Continuous Integration and Continuous Delivery. 

  2. WLS for OKE Jenkins: Jenkins provisioned by WLS for OKE stack.

  3. Developer’s Jenkins: Jenkins installed by the user in the development environment to run a script that triggers update_domain pipeline job on WLS for OKE Jenkins. 

  4. x.y.z.104 Represents the public IP address of the external load balancer.

  5. x.y.z.188 Represents the public IP address of the bastion host