Search

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

download PDF

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 add-ons 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 rhdm73-optaweb-employee-rostering

    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. Run 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.4.0-openshift-templates.zip file from the Software Downloads page for Red Hat Decision Manager 7.4.
    7. Extract the rhdm74-image-streams.yaml file.
    8. Complete one of the following actions:

      • Run the following command:

        $ oc create -f rhdm74-image-streams.yaml
      • Using the OpenShift Web UI, select Add to Project Import YAML / JSON and then choose the file or paste its contents.

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.4.0-openshift-templates.zip file from the Software Downloads page for Red Hat Decision Manager 7.4.
  2. Unzip the downloaded archive and locate the rhdm74-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 rhdm74-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>/rhdm74-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.4.0-add-ons.zip file from the Software Downloads page for Red Hat Decision Manager 7.4.
  2. Unzip the downloaded archive.
  3. Unzip the rhdm-7.4.0-employee-rostering.zip file that is extracted from the add-ons archive.
  4. Using the command line, change to the optaweb-employee-rostering-7.23.0.Final-redhat-00002/sources folder.
  5. 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 …​.

  6. 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.

  7. 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
Red Hat logoGithubRedditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.