Bookmark this page

Guided Exercise: Deploying Applications by Using the Red Hat OpenShift Web Console

Deploy simple applications by using the various methods that the Red Hat OpenShift web console provides.

Outcomes

  • Deploy an application by using a Git repository.

  • Deploy an application by using an image from a container registry.

As the student user on the workstation machine, use the lab command to prepare your system for this exercise.

[student@workstation ~]$ lab start deploy-console

This command creates the deploy-console project in the Red Hat OpenShift Container Platform (RHOCP) cluster.

Instructions

Deploy the following two applications in the deploy-console project.

NameRuntimeStrategy
hello-world PHPImport from the apps/deploy-console/php-helloworld directory of the https://git.ocp4.example.com/developer/DO288-apps.git repository
todo-list Node.jsFrom the registry.ocp4.example.com:8443/redhattraining/openshift-dev-deploy-console-todo-list container image
  1. Log in to RHOCP and select the developer perspective.

    1. Open a web browser and navigate to https://console-openshift-console.apps.ocp4.example.com. Click htpasswd_provider and log in as the developer user with the developer password.

    2. From the side menu, click Developer to ensure that you use the developer perspective.

    3. Ensure that the selected project is deploy-console.

  2. Deploy the PHP application from the Git repository.

    1. Click +Add to open the Add page.

    2. In the Git Repository card, click Import from Git.

    3. Enter https://git.ocp4.example.com/developer/DO288-apps.git in the Git Repo URL field. You might see a warning indicating that the repository is not reachable.

    4. In the Git type field, select GitLab. The web console validates the repository.

    5. Click Show advanced Git options, then enter apps/deploy-console/php-helloworld in the Context dir field. The form detects that the directory contains a PHP application and changes the import strategy to the PHP 8.0 (UBI) builder image.

    6. Under the General section, enter hello-world in the Application name and Name fields.

    7. Under the Advanced options section, ensure that the target port is 8080 and the Create a route option is selected.

    8. Click Create. The web console redirects you to the topology view.

  3. Verify that the hello-world PHP application has been deployed successfully.

    1. In the topology view, verify that the hello-world application is running. After a few seconds, the circular border of the hello-world deployment must transition from light blue to dark blue, which indicates that the application pod is running.

    2. Click the Open URL icon.

    3. On the hello-world tab that opens, verify that the application response is similar to the following message:

      Hello, World! php version is ...
  4. Deploy the Node.js application.

    1. Click +Add to open the Add page.

    2. Click Container images.

    3. Enter registry.ocp4.example.com:8443/redhattraining/openshift-dev-deploy-console-todo-list as the image name from the external registry.

    4. From the Runtime icon list, select nodejs.

      Note

      This change can help you identify the deployment as a Node.js application in the topology view.

    5. Under the General section, select Create application in the Application field.

    6. Enter todo-list in the Application name and Name fields.

    7. Under the Advanced options section, ensure that the target port is 3000 and the Create a route option is selected.

    8. Click Create. The web console redirects you to the topology view.

  5. Verify that the todo-list Node.js application has been deployed successfully.

    The application exposes a /todos endpoint that accepts POST and GET actions. Test that these actions create and retrieve items.

    1. In the topology view, verify that the todo-list application is running. The todo-list deployment icon must display a dark blue circle, a few seconds after you create the application.

    2. Click the Node.js application icon to open the deployment details.

    3. In the side pane that opens, click Resources.

    4. Copy the URL under the Routes section.

    5. Test that the application can create items.

      Return to the terminal and use the copied URL to send a POST request to the /todos endpoint, by running the following command:

      [student@workstation ~]$ curl -i -H "Content-Type: application/json" \
      https://todo-list-deploy-console.apps.ocp4.example.com/todos \
      --data '{ "task": "Say hello" }'
      HTTP/1.1 201 Created
      ...output omitted...

      The application saves the item and returns a 201 Created HTTP response.

    6. Retrieve the list of items by running the following command:

      [student@workstation ~]$ curl -s \
      https://todo-list-deploy-console.apps.ocp4.example.com/todos | jq
      [
        {
          "task": "Say hello"
        }
      ]

Finish

On the workstation machine, use the lab command to complete this exercise. This step is important to ensure that resources from previous exercises do not impact upcoming exercises.

[student@workstation ~]$ lab finish deploy-console

Revision: do288-4.12-0d49506