Chapter 2. Installing and starting the employee rostering starter application on OpenShift

You can deploy the Red Hat Business Optimizer Employee Rostering starter application to Red Hat OpenShift Container Platform using an OpenShift template or using the provision.sh shell script that is provided in the reference implementation distribution.

If you use an OpenShift template, Red Hat OpenShift Container Platform loads an image with the application from the Red Hat repository and deploys it. This method of deployment is a technological preview.

If you use the script, it builds and packages the application source code locally and uploads it to the OpenShift environment for deployment. You can use this method when Java developer tools (Java Development Kit and Maven) and a bash shell command line are available.

Important

In the deployed application, the data is held in memory and lost when the pod is restarted.

2.1. Deploying the application using the template

To deploy the application using the template, you must first ensure that the image streams for Red Hat Decision Manager are available and configure OpenShift registry authentication. Then you can deploy the template.

The template deploys a pod with the Employee Rostering starter application and a separate pod with a PostgreSQL database server. The application uses the database server for persistent storage of all the information that it uses.

Prerequisites

  • You are logged in to the target OpenShift environment using the Web UI or using the oc command line tool. For more information about this tool, see CLI Reference.

2.1.1. Ensuring the availability of image streams and the image registry

To deploy the Employee Rostering starter application on Red Hat OpenShift Container Platform, you must ensure that OpenShift can download the correct images from the Red Hat registry. To download the images, OpenShift requires the information about their location (known as image streams). OpenShift also must be configured to authenticate with the Red Hat registry using your service account user name and password.

Some versions of the OpenShift environment include the required image streams. You must check if they are available. If image streams are available in OpenShift by default, you can use them if the OpenShift infrastructure is configured for registry authentication server. The administrator must complete the registry authentication configuration when installing the OpenShift environment.

Procedure

  1. Determine whether Red Hat OpenShift Container Platform is configured with the user name and password for Red Hat registry access. For details about the required configuration, see Configuring a Registry Location. If you are using an OpenShift Online subscription, it is configured for Red Hat registry access.
  2. If Red Hat OpenShift Container Platform is configured with the user name and password for Red Hat registry access, run the following command:

    $ oc get imagestreamtag -n openshift | grep rhdm-optaweb-employee-rostering | grep 7.5

    If the output of the command is not empty, the required image streams are available in the openshift namespace and no further action is required.

  3. If the output of the command is empty or if OpenShift is not configured with the user name and password for Red Hat registry access, complete the following steps:

    1. Ensure you are logged in to OpenShift with the oc command and that your project is active.
    2. Complete the steps documented in Registry Service Accounts for Shared Environments. You must log in to Red Hat Customer Portal to access the document and to complete the steps to create a registry service account.
    3. Select the OpenShift Secret tab and click the link under Download secret to download the YAML secret file.
    4. View the downloaded file and note the name that is listed in the name: entry.
    5. Enter the following commands:

      oc create -f <file_name>.yaml
      oc secrets link default <secret_name> --for=pull
      oc secrets link builder <secret_name> --for=pull

      Replace <file_name> with the name of the downloaded file and <secret_name> with the name that is listed in the name: entry of the file.

    6. Download the rhdm-7.5.1-openshift-templates.zip file from the Software Downloads page for Red Hat Decision Manager 7.5.
    7. Extract the rhdm75-image-streams.yaml file.
    8. Enter the following command:

      $ oc apply -f rhdm75-image-streams.yaml
      Note

      If you complete these steps, you install the image streams into the namespace of your project. If you install the image streams using these steps, you must set the IMAGE_STREAM_NAMESPACE parameter to the name of this project when deploying templates.

2.2. Creating the secrets for the Employee Rostering application

You must create an SSL certificate for HTTP access to the Employee Rostering application and provide it to your OpenShift environment as a secret.

Procedure

  1. Generate an SSL keystore with a private and public key for SSL encryption for Decision Server. For more information on how to create a keystore with self-signed or purchased SSL certificates, see Generate a SSL Encryption Key and Certificate.

    Note

    In a production environment, generate a valid signed certificate that matches the expected URL for the Employee Rostering application.

  2. Save the keystore in a file named keystore.jks.
  3. Record the name of the certificate. The default value for this name in Red Hat Decision Manager configuration is jboss.
  4. Record the password of the keystore file. The default value for this name in Red Hat Decision Manager configuration is mykeystorepass.
  5. Use the oc command to generate a secret named optaweb-employee-rostering-app-secret from the new keystore file:

    $ oc create secret generic optaweb-employee-rostering-app-secret --from-file=keystore.jks

2.2.1. Deploying the OpenShift template

You can deploy an OpenShift template to create an environment running the Employee Rostering starting application.

Procedure

  1. Download the rhdm-7.5.1-openshift-templates.zip file from the Software Downloads page for Red Hat Decision Manager 7.5.
  2. Unzip the downloaded archive and locate the rhdm75-optaweb-employee-rostering.yaml file.
  3. Use one of the following methods to deploy the template:

    • In the OpenShift Web UI, select Add to Project → Import YAML / JSON and then select or paste the rhdm75-optaweb-employee-rostering.yaml file. In the Add Template window, ensure Process the template is selected and click Continue.
    • To use the OpenShift command line console, prepare the following command line:

      oc new-app -f <template-path>/rhdm75-optaweb-employee-rostering.yaml -p OPTAWEB_HTTPS_SECRET=optaweb-employee-rostering-app-secret

      In this command line:

      • Replace <template-path> with the path to the downloaded template file.
      • Add as many -p PARAMETER=value pairs as needed to set the required parameters. You can view the template file to see descriptions for all parameters.
  4. Set the following parameters as necessary:

    • Optaweb Employee Rostering Keystore Secret Name (OPTAWEB_HTTPS_SECRET): The name of the secret for HTTPS connections, as created in Section 2.2, “Creating the secrets for the Employee Rostering application”.
    • Application Name (APPLICATION_NAME): The name of the OpenShift application. It is used in the default URL for the application.
    • OptaWeb Admin User (OPTAWEB_ADMIN_USER): The user name for the administrative user in the application. The default user name is adminUser.
    • OptaWeb Admin Password (OPTAWEB_ADMIN_PWD): The password for the administrative user in the application. The default password is RedHat.
    • ImageStream Namespace (IMAGE_STREAM_NAMESPACE): The namespace where the image streams are available. If the image streams were already available in your OpenShift environment (see Section 2.1.1, “Ensuring the availability of image streams and the image registry”), the namespace is openshift. If you installed the image streams file, the namespace is the name of the OpenShift project.
    • Optaweb Employee Rostering Container Memory Limit (OPTAWEB_MEMORY_LIMIT): The memory limit for the application container. The higher the limit, the more employees and shifts are supported. The default is 1 Gi.
    • Optaweb Employee Rostering Generator Zone ID (OPTAWEB_GENERATOR_ZONE_ID): The time zone that is set in the generated example data sets in the application. The default is the local time zone of the OpenShift server.
  5. Complete the creation of the environment, depending on the method that you are using:

    • In the OpenShift Web UI, click Create.

      • If the This will create resources that may have security or project behavior implications pop-up message is displayed, click Create Anyway.
    • Complete and run the command line.

2.3. Deploying the application using the provided script

You can deploy the Red Hat Business Optimizer Employee Rostering starter application to Red Hat OpenShift Container Platform using the provided script. The script builds and packages the application source code locally and uploads it to the OpenShift environment for deployment.

Prerequisites

  • You are logged in to the target OpenShift environment using the oc command line tool. For more information about this tool, see CLI Reference.
  • Maven and a Java Development Kit are installed on your local machine.
  • A bash shell environment is available on your local machine.

Procedure

  1. Download the rhdm-7.5.1-maven-repository.zip file from the Software Downloads page of the Red Hat Customer Portal.
  2. Expand the downloaded archive.
  3. Copy the contents of the jboss-rhba-7.5.1.GA-maven-repository/maven-repository subdirectory into the ~/.m2 directory.
  4. Download the rhdm-7.5.1-reference-implementation.zip file from the Software Downloads page of the Red Hat Customer Portal.
  5. Expand the downloaded archive.
  6. Unzip the rhdm-7.5-employee-rostering.zip file that is extracted from the reference implementation archive.
  7. Using the command line, change to the employee-rostering-distribution-7.26.0.Final-redhat-00005/sources folder.
  8. Run the provision script to build and deploy the application:

    ./provision.sh setup employee-rostering --binary
    Note

    If the current OpenShift user name contains characters that are not letters or numbers, the deployment might fail. You can resolve this issue by providing an additional parameter: ./provision.sh setup employee-rostering --binary --project-suffix optaweb. This example uses "optaweb", but you can use any value for the suffix.

    Compilation and packaging might take up to 10 minutes to complete. These processes continually show progress on the command line output.

    When the operation is completed, the following message is displayed: Uploading file "target/ROOT.war" as binary input for the build …​.

  9. Use the OpenShift web UI to view the details for the deployed application. Click the link in the Routes section to open the starter application. The first startup can take up to a minute as additional building is completed on the OpenShift platform.

    Note

    If the application does not open for more than a minute after clicking the link, perform a hard refresh of your browser page.

  10. Optionally, you can use other actions provided by the provision script:

    1. Deploy updates to the code to an existing deployment:
./provision.sh deploy employee-rostering --binary

+ .. Remove the application:

./provision.sh delete employee-rostering