Deploying the WebSphere Liberty operator sample application

After the operator installation, an application administrator can deploy the sample application image for WebSphereLibertyApplication to a Kubernetes environment. Deploy the application image with the Red Hat® OpenShift® console or with kubectl or oc commands.

The WebSphere® Liberty operator must be installed on all namespaces or in the namespace where you want to deploy the sample application.

The deployed sample application shows the system properties for the application in a browser.

The successfully deployed sample application browser page, with the system properties for the application and their values shown in tabular format

Deploying the sample application with the Red Hat OpenShift console

  1. In the Red Hat OpenShift console navigation menu, click Operators > Installed Operators.
  2. On the Installed Operators page, create a project for the sample.
    1. Select the project for the operator installation from the Project list and ensure that IBM WebSphere Liberty is in the list of installed operator names. The operator must be installed on the cluster or in the project in which you want to install the sample.
    2. Expand the Project list and click Create Project.
    3. In the Create Project dialog, specify a Name value such as samplelibertyapp and click Create.
    4. With the samplelibertyapp project selected in the Project list, click the IBM WebSphere Liberty operator.
      Select the IBM WebSphere Liberty operator on the Red Hat OpenShift Installed Operators page
  3. On the Operator details page, create an instance of the WebSphereLibertyApplication sample application.
    1. Click the WebSphereLibertyApplication tab.
    2. Click Create WebSphereLibertyApplication.
      Click the Create WebSphereLibertyApplication button on the IBM WebSphere Liberty operator details page
  4. On the Create WebSphereLibertyApplication page, configure the application in the Form view or in the YAML view. You can use the Form view to change operator parameter values and then use the YAML view to see the configured application CR.

    To configure the application in the Form view, complete the following steps.

    1. Expand License and select accept.
    2. Set the Expose value to true.
    3. Click Create.

    To configure the application in the YAML view, ensure that the CR has the following changes.

    • The .spec.license.accept parameter must be set to true to accept the license.
    • The .spec.expose parameter must be set it to true to expose the application with a route so that you can run and view the sample application.

    The .spec.applicationImage parameter value for the sample application does not require changes. It already specifies the path to the sample application that is provided with the WebSphere Liberty operator.

    After changes, the YAML resembles the following CR.

    apiVersion: liberty.websphere.ibm.com/v1
    kind: WebSphereLibertyApplication
    metadata:
      name: websphereliberty-app-sample
      namespace: samplelibertyapp
    spec:
      license:
        accept: true
        edition: IBM WebSphere Application Server
        productEntitlementSource: Standalone
      applicationImage: >-
        icr.io/appcafe/open-liberty/samples/getting-started@sha256:e22dd56a05e44618a10d275d3ff07a38eb364c0f04f86ffe9618d83dd5467860
      manageTLS: true
      expose: true
  5. In the Red Hat OpenShift console navigation menu, click Workloads > Pods to ensure that the pod on which you installed the sample application is running.
  6. In the Red Hat OpenShift console navigation menu, click Networking > Routes to see the route of the sample application. Click the Location link to run the sample application and view it in a browser.

Deploying the sample application with the CLI

  1. Configure a custom resource (CR) YAML file for the WebSphereLibertyApplication to deploy the sample application. Ensure that the CR has the following settings.
    • The .spec.license.accept value must specify true.

    • If your product edition is other than the default, IBM WebSphere Application Server (base), the .spec.license.edition value must specify your product edition. Other available values are IBM WebSphere Application Server Liberty Core and IBM WebSphere Application Server Network Deployment.

    • If the product for which you have a license is other than the default, Standalone, which includes WebSphere Application Server products such as Liberty, the .spec.license.productEntitlementSource value must specify another product. Other available options are IBM Cloud Pak for Applications, IBM WebSphere Application Server Family Edition, and IBM WebSphere Hybrid Edition.

    • The .spec.applicationImage parameter value must specify the path to the sample application that is provided with the WebSphere Liberty operator.

    • The .spec.expose parameter must be set it to true to expose the application with a route so that you can run and view the sample application.

    The following CR sets .spec.license.accept to true for the IBM WebSphere Application Server stand-alone product, specifies a path to the application image with .spec.applicationImage, and sets .spec.expose to true.

    apiVersion: liberty.websphere.ibm.com/v1
    kind: WebSphereLibertyApplication
    metadata:
      name: websphereliberty-app-sample
      namespace: samplelibertyapp
    spec:
      license:
        accept: true
        edition: IBM WebSphere Application Server
        productEntitlementSource: Standalone
      applicationImage: >-
        icr.io/appcafe/open-liberty/samples/getting-started@sha256:e22dd56a05e44618a10d275d3ff07a38eb364c0f04f86ffe9618d83dd5467860
      manageTLS: true
      expose: true

    By default, .spec.manageTLS is set to true and does not need to be specified in the CR. If you deploy the CR to a Kubernetes cluster, you must have certificate manager installed on the Kubernetes cluster. If you deploy the CR to an Red Hat OpenShift cluster, then the certificate manager installation is not required.

  2. Deploy your CR to a running cluster in a Kubernetes environment.

    To use the CLI to apply your CR, run a kubectl apply or oc apply command.

    To run kubectl commands, you need the Kubernetes command line tool or the Red Hat OpenShift command-line interface (CLI). To run oc commands, you need the Red Hat OpenShift CLI.

    In the following apply commands, replace CR-YAML with your CR file name.

    • Run the following kubectl apply command.
      kubectl apply -f CR-YAML
    • Run the following oc apply command.
      oc apply -f CR-YAML
  3. Check that sample application pods are running.
    kubectl get pods -n samplelibertyapp
    oc get pods -n samplelibertyapp
  4. Get the route of the application.
    kubectl get routes -n samplelibertyapp
    oc get routes -n samplelibertyapp

    The output has a HOST/PORT value that provides a URL to the sample application.

    NAME                          HOST/PORT                                                   PATH   SERVICES                      PORT       TERMINATION   WILDCARD
    websphereliberty-app-sample   websphereliberty-app-sample-samplelibertyapp.apps.ibm.com          websphereliberty-app-sample   9443-tcp   reencrypt     None
    
  5. Copy the URL (HOST/PORT) from the route and view the deployed sample application in a browser.