Eric D. Schabell: CodeReady Containers - Installing business automation operator (Part 4)

Tuesday, January 5, 2021

CodeReady Containers - Installing business automation operator (Part 4)

As a consistent user and developer on the OpenShift platform over the years, I've tried helping users by sharing my application development content as we've journeyed from  cartridges all the way to container base development.

With container based development we've also transitioned from using templates to define how to deploy our tooling and applications, to operators. There are many examples of how to work with the templated versions of our applications around decision management and process automation found on Red Hat Demo Central and JBoss Demo Central.

Over the releases of OpenShift 4.x we've seen that operators have become the preferred method of packaging, deploying and managing a Kubernetes-native, thus OpenShift, application. With this in mind it felt like time to explore and update existing demos and example projects to employ the provided operators for installation and runtime.

In this series of articles I'll be providing a walk through what it is to use the latest tooling provided by the business automation operator on the OpenShift Container Platform. We'll install the operator by hand, start instances of the decision management and process automation tooling using the OpenShift console, explore command line automation of installing, starting, and configuring the same tooling from the command line, and share a fully automated process automation tooling installation with pre-installed example project.

In the previous article we've installed the business automation operator in the OpenShift web console, installed the provided decision management  and process automation tooling. In our final article of this series, let's install the business automation operator and its provided developer tooling using the command line.


Command line operator installation

The starting point in this article is that you have installed OpenShift using CodeReady Containers as shown in  part one, which makes used of my project that validates your environment ensuring you have the proper OpenShift client tooling known as oc client.

This client tooling is what we need to interact with the OpenShift platform APIs and is a mainstay for both developers and operations. In this article we'll be using this client tooling as a developer as much as possible, but some of our actions require administrator access to set up the operator installation. 

If you chose for some reason to install the CodeReady Containers yourself then you might not have the initial set up described here. In that case you will have seen a message in your startup logs (after running  crc start) that points you to the provided client, shown here for a unix based environment from your favorite console:

$ crc oc-env
    
export PATH="/Users/eschabel/.crc/bin/oc:$PATH"
# Run this command to configure your shell:
# eval $(crc oc-env)

If you test the version of this client executable, you'll find that it matches the version of the OpenShift platform:

$ ~/.crc/bin/oc/oc version --client
    
Client Version: 4.6.6  

The first thing we need to do is ensure you are logged in to your OpenShift platform, which is provided in the start up logs (all one line):

$ oc login -u developer -p developer https://api.crc.testing:6443  

Let's set up a new project called appdev-in-cloud:

$ oc new-project appdev-in-cloud
    
Now using project "appdev-in-cloud" on server "https://api.crc.testing:6443".  

There is more output lines following the project creation, but they are not that important to us right now. If you want to verify that this project exists you can list your users projects with:

$ oc get projects  

This will list the newly created appdev-in-cloud project as active. Next up, let's take a closer look at preparing to install the business automation operator from our client tooling. This requires admin user access for the next two actions, so let's switch users:

$ oc login -u kubeadmin -p HERE https://api.crc.testing:6443

Note your kubeadmin user password was generated during the CodeReady Containers installation and should be used instead of my placeholder above. The login will report access to many more projects, but is currently using  your appdev-in-cloud project.

There are two steps needed before you can install the business automation operator in the project appdev-in-cloud. First you need to define the operator group, which is done by creating a file called create-operatorgroup.yaml that contains the following lines:

apiVersion: operators.coreos.com/v1
    kind: OperatorGroup
    metadata:
      annotations:
        olm.providedAPIs: KieApp.v2.app.kiegroup.org
      name: businessautomation-operator
      namespace: appdev-in-cloud
    spec:
      targetNamespaces:
      - appdev-in-cloud  

Once you have this file available, you can apply it to your project with the following:

$ oc apply -f create-operatorgroup.yaml
   
operatorgroup.operators.coreos.com/businessautomation-operator created  

The output shows that the group was successfully created. Now we need to set the subscription for this operator, done by creating a file called sub-operator.yaml that contains the following lines:

apiVersion: operators.coreos.com/v1alpha1
    kind: Subscription
    metadata:
      name: businessautomation-operator
      namespace: appdev-in-cloud
    spec:
      channel: stable
      installPlanApproval: Automatic
      name: businessautomation-operator
      source: redhat-operators
      sourceNamespace: openshift-marketplace

Once you have this file available, you can apply it the same as the previous one:

$ oc apply -f sub-operator.yaml
   
subscription.operators.coreos.com/businessautomation-operator created  

The output again shows the subscription was successfully created. Now you can see that the business automation operator is installed (if you like, using the OpenShift web console as you did in part one of this series) with the following:

$ oc get operators  

This lists your operator as ready to install. For the final part you can install either one of the provided tools, either Red Hat Decision Manager or Red Hat Process Automation Manager, by using their respective definitions. First log back in as the developer user:

$ oc login -u developer -p developer https://api.crc.testing:6443

Then create a file called kieapp-rhdm-authoring.yaml and put the following in it:

apiVersion: app.kiegroup.org/v2
    kind: KieApp
    metadata:
      name: rhdm
    labels:
      app: crc-rhdm-install
    namespace: appdev-in-cloud
  spec:
    commonConfig:
      adminPassword: redhatdm1!
      adminUser: erics
      applicationName: rhdm
    environment: rhdm-authoring  

This file creates the same instance of the tooling you experienced with part two of this series. To do this from the client tooling, just run the following command:

$ oc apply -f kieapp-rhdm-authoring.yaml
    
kieapp.app.kiegroup.org/rhdm created  

This starts the installation of an instance of the decision management tooling based on the operator you added to the project appdev-in-cloud. View the installation progress with the following:

$ oc get pods  

The output lists the operator and other pods being set up, initially the status will be ContainerCreating. This takes some time, but when they are fully operational the status should change to Completed. The same can be done for process automation tooling, just like you did in part three of this series by creating a file called kieapp-rhpam-authoring.yaml and putting the following in it:

apiVersion: app.kiegroup.org/v2
    kind: KieApp
    metadata:
      name: rhpam
      labels:
        app: crc-rhpam-install
      namespace: appdev-in-cloud
    spec:
      commonConfig:
        adminPassword: redhatpam1!
        adminUser: erics
        applicationName: rhpam
      environment: rhpam-authoring  

Start the instance creation from the client tooling by running the following command:

$ oc apply -f kieapp-rhpam-authoring.yaml
    
kieapp.app.kiegroup.org/rhpam created  

This starts the installation of an instance of the decision management tooling based on the operator you added to the project appdev-in-cloud. View the installation progress with the following:

$ oc get pods  

Again, you'll find pods starting to install process automation tooling in the status ContainerCreating, after some time they will change to Completed. If you are having issues with memory running out, you can remove the project after installing the decision management tooling with the following command:

$ oc delete project appdev-in-cloud  

Once this completes it's removal of the project, you can recreate appdev-in-cloud and install the process automation tooling using the above file. This completes your tour of installing the business automation operator using the client tooling, then leveraging the operator to install both of the provided developer tooling options.

Missed part of the series?

Not a worry if you missed any of the previous articles in this four part series, just check out how you can install the container platform (hopefully being able to use the CodeReady Containers Easy Local Install project), then learn how to install the business automation operator, followed by a look at installing the decision management and process automation tooling provided by this operator using the OpenShift web console. Finally, in this last article we've installed the business automation operator and offered developer tools using the OpenShift client tooling from a command line. 

If you have any comments for feedback, please reach out. I hope you enjoyed this series and tour.