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.
- Deploying the sample application with the Red Hat OpenShift console
- Deploying the sample application with the CLI
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.

Deploying the sample application with the Red Hat OpenShift console
- In the Red Hat OpenShift console navigation menu, click .
- On the Installed Operators page, create a project for the sample.
- 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.
- Expand the Project list and click Create Project.
- In the Create Project dialog, specify a Name value such as
samplelibertyapp
and click Create. - With the
samplelibertyapp
project selected in the Project list, click the IBM WebSphere Liberty operator.
- On the Operator details page, create an instance of the WebSphereLibertyApplication sample application.
- Click the WebSphereLibertyApplication tab.
- Click Create WebSphereLibertyApplication.
-
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.
- Expand License and select accept.
- Set the Expose value to
true
. - 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
- In the Red Hat OpenShift console navigation menu, click to ensure that the pod on which you installed the sample application is running.
- In the Red Hat OpenShift console navigation menu, click 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
- Configure a custom resource (CR) YAML file for the WebSphereLibertyApplication to deploy the sample application. Ensure
that the CR has the following settings.
The following CR sets .spec.license.accept to
true
for theIBM WebSphere Application Server
stand-alone product, specifies a path to the application image with .spec.applicationImage, and sets .spec.expose totrue
.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. - 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 runoc
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
- Run the following kubectl apply
command.
- Check that sample application pods are
running.
kubectl get pods -n samplelibertyapp
oc get pods -n samplelibertyapp
- 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
- Copy the URL (
HOST/PORT
) from the route and view the deployed sample application in a browser.