Software and Systems How-To's, Tutorials, Demos, Notes

How to Develop MarkLogic Applications in OpenShift Using CI/CD

Assumptions

[root@openshiftdev OpenShiftHowToGuides]# oc whoami
admin
[root@openshiftdev ~]# oc login -u admin
Logged into "https://10.0.2.15:8443" as "admin" using existing credentials.

You have access to the following projects and can switch between them with 'oc project <projectname>':

  * default
    kube-system
    myproject
    openshift
    openshift-infra

Using project "default".

Build the MarkLogic 9 Docker Image

Push the MarkLogic Docker image to OpenShift namespace

docker tag marklogic9 172.30.1.1:5000/openshift/marklogic9
- This should create an ImageStream in the openshift namespace. You can check this by issuing the command:

[root@openshiftdev OpenShiftHowToGuides]# oc get is -n openshift|grep marklogic marklogic9 172.30.1.1:5000/openshift/marklogic9 latest About a minute ago


- You can view the contents of the ImageStream config file by issuing this command:

[root@openshiftdev ~]# oc export is marklogic9 -n openshift apiVersion: v1 kind: ImageStream metadata: creationTimestamp: null generation: 1 name: marklogic9 spec: tags:

Create DEV environment

curl https://raw.githubusercontent.com/corpbob/OpenShiftHowToGuides/marklogic/marklogic/slush-marklogic-node-templatel.yml -o slush-marklogic-node-templatel.yml
oc new-project ml-dev
oc new-app slush-marklogic-node-app

slush-marklogic-node-overview.png

oc create -f slush-marklogic-node-pipeline.yml 

You should see a jenkins service was added:

images/ml-node-dev-cicd.png

Navigate to the pipeline to see it:

images/ml-node-navigate-pipeline.png

The pipeline that is yet to be started looks like:

images/ml-node-pipeline-1.png

However, we cannot start this yet. We need to create the UAT Environment.

Create UAT Environment

oc new-project ml-uat
oc new-app slush-marklogic-node-app

TODO: this image should be uat environment. slush-marklogic-node-uat-overview.png

We need to give jenkins service account in mlnode project edit access to mlnode-uat

[root@localhost marklogic]# oc policy add-role-to-user edit system:serviceaccount:ml-dev:jenkins -n ml-uat
role "edit" added: "system:serviceaccount:ml-dev:jenkins"

Running the CI/CD Pipeline

If you click on the jenkins like you’ll find the pipeline:

images/ml-node-jenkins-1.png

Start the pipeline

images/ml-node-start-pipeline-2.png

You can also look at the jenkins log:

images/ml-node-start-pipeline-3.png

Wait for Approval

At this stage the pipeline will wait for an Approver to give the go-signal.

images/ml-node-pipeline-wait-approval.png

Click on Approve to deploy to UAT

images/ml-node-pipeline-approval.png

Pipeline Deploying to UAT

images/ml-node-pipeline-deploy-uat.png

Congratulations! You just deployed to UAT using the pipeline!

images/ml-node-pipeline-uat-deployed.png

Click on the route above to launch the slush-marklogic-node app. You shoud see something like this:

images/slush-marklogic-node-app-page.png

Login the the application using credentials

username: admin
password: admin

images/slush-marklogic-node-app-login.png

Click on the search menu to get the following:

images/slush-marklogic-node-app-search.png

Congratulations you have now completed CI/CD setup of MarkLogic on OpenShift!