Chapter 5. OpenShift basics in CodeReady Studio

CodeReady Studio includes the OpenShift Application Explorer view, which provides a simplified user experience allowing easy and rapid feedback through the inner loop as well as debugging.

The OpenShift Application Explorer is set in CodeReady Studio as the default view. In case you need to open it manually, follow the instuctions in Setting Up Openshift App Explorer View.

5.1. Setting up the OpenShift Application Explorer view

The following section describes how to open OpenShift Application Explorer in CodeReady Studio.

Procedure

  1. Start CodeReady Studio.
  2. Click WindowShow ViewOther.

    crs window show view other

    The Show View window appears.

    crs select openshift app explorer
  3. Enter OpenShift in the search field.
  4. Select OpenShift Application Explorer.
  5. Click Open.

    The OpenShift Application Explorer view appears.

crs openshift app explorer view

5.2. Connecting to the OpenShift cluster using OpenShift Application Explorer

The following section describes how to login to the OpenShift cluster in CodeReady Studio using OpenShift Application Explorer.

Procedure

  1. Start CodeReady Studio.
  2. Open OpenShift Application Explorer.
  3. Click Can’t connect to cluster. Click to login.

    login to openshift cluster

    The Login window appears.

    crs login credentials os cluster
  4. Enter your username and password or token.
  5. Click the Finish button.

Your projects now appear in the OpenShift Application Explorer view.

5.3. Building an application based on devfiles

To deploy applications based on devfiles, you need an empty project in your local workspace as well as an empty project in OpenShift, for which you need to create a devfile component. After the component is established, your project will be updated and local and remote artifacts created in OpenShift.

5.3.1. Creating an empty project

The following section describes how to create an empty project in CodeReady Studio.

Procedure

  1. Start CodeReady Studio.
  2. Press Ctrl+N.

    The Select a wizard window appears.

    crs create empty project in pe 1
  3. Select GeneralProject.
  4. Click Next.

    The New Project window appears.

    crs create empy project in pe
  5. Name your project.
  6. Select the location for your project.
  7. Click Finish.

Your newly created empty project is now listed in the Project Explorer view.

5.3.2. Creating an empty OpenShift project using OpenShift Application Explorer

The following section describes how to create an empty project using OpenShift Application Explorer in CodeReady Studio.

Procedure

  1. Start CodeReady Studio.
  2. Start OpenShift Application Explorer.
  3. Right-click any place in OpenShift Application ExplorerNewProject.

    crs os project

    The New project window appears.

    crs os new project window
  4. Name your project.
  5. Click OK.

Your newly created project is now listed in the OpenShift Application Explorer view.

5.3.3. Creating a devfile component using OpenShift Application Explorer

The following section describes how to create a devfile component using OpenShift Application Explorer in CodeReady Studio.

Procedure

  1. Start CodeReady Studio.
  2. Start OpenShift Application Explorer.
  3. Right-click the target ProjectNewComponent.

    crs os new component

    The Create component window appears.

    crs devfile component type

  4. Name your project.
  5. Click Browse to select your Eclipse Project.
  6. Set your Component type to java-vertx.
  7. Set the Project starter to java-vertx.
  8. Name your application.
  9. Clear the Push after create check box.
  10. Click Finish.

The Console view appears, displaying the validation process.

Your newly created component is now listed in the OpenShift Application Explorer view under your project.

5.4. Building an application based on S2I files

To deploy applications based on S2I files, you need a launcher project in your local workspace as well as an empty project in OpenShift, for which you need to create a component. After the component is established, your project will be updated and local and remote artifacts created in OpenShift.

5.4.1. Creating a launcher project

The following section describes how to create a launcher project in CodeReady Studio.

Procedure

  1. Start CodeReady Studio.
  2. Press Ctrl+N.

    The Select a wizard window appears.

    crs launcher project wizard
  3. Enter Launcher in the search field.
  4. Select Launcher project.
  5. Click Next.

    The New Launcher project window appears.

    crs launcher project creation
  6. Set Mission to rest-http.
  7. Set Runtime to vert.x community.
  8. Name your project.
  9. Select the location for your project.
  10. Click Finish.

    Note that the process of resolving dependencies might take some time to complete.

Your newly created launcher project is now listed in the Project Explorer view.

5.4.2. Creating an empty OpenShift project in OpenShift Application Explorer

The following section describes how to create an empty project using OpenShift Application Explorer in CodeReady Studio.

Procedure

  1. Right-click any place in OpenShift Application ExplorerNewProject.

    crs os project

    The New project window appears.

    crs os new project window
  2. Name your project.
  3. Click OK.

Your newly created project is now listed in the OpenShift Application Explorer view.

5.4.3. Creating an S2I component using OpenShift Application Explorer

The following section describes how to create a component using OpenShift Application Explorer in CodeReady Studio.

Procedure

  1. Start CodeReady Studio.
  2. Start OpenShift Application Explorer.
  3. Right-click the target ProjectNewComponent.

    crs os new component

    The Create component window appears.

    crs s2i component

  4. Name your project.
  5. Click Browse to select your Eclipse Project.
  6. Click on the arrow next to S2I and set your Component type to java.
  7. Set the Component version to latest.
  8. Name your application.
  9. Clear the Push after create check box.
  10. Click Finish.

The Console view appears, displaying the validation process.

Your newly created component is now listed in the OpenShift Application Explorer view under your project.

5.5. Deploying a component on a cluster using OpenShift Application Explorer

The following section describes how to deploy a component on a cluster using OpenShift Application Explorer in CodeReady Studio.

Procedure

  1. Start CodeReady Studio.
  2. Start OpenShift Application Explorer.
  3. Expand your project.
  4. Expand your application.
  5. Right-click your componentPush.

    crs os push

    The Console view appears, displaying the process of file synchronization.

5.6. Defining an external access URL using OpenShift Application Explorer

The following section describes how to define an external access URL using OpenShift Application Explorer in CodeReady Studio.

Procedure

  1. Start CodeReady Studio.
  2. Start OpenShift Application Explorer.
  3. Expand your project.
  4. Expand your application.
  5. Right-click your componentNewURL.

    crs os new url

    The Create URL window appears.

    crs os create url window
  6. Name your URL.
  7. Set the Port value to 8080.
  8. Click Finish.

    The Console view appears, displaying the process of URL creation.

  9. In OpenShift Application Explorer, right-click your componentPush.

    crs os push

    The Console view appears, displaying the process of file synchronization.

Your newly created URL is now listed in the OpenShift Application Explorer view under your component.

5.7. Debugging an application on a cluster using OpenShift Application Explorer

The following section describes how to debug an application on a cluster using OpenShift Application Explorer in CodeReady Studio.

Procedure

  1. Start CodeReady Studio.
  2. In the Project Explorer view, locate the MainVerticle.java(devfiles) or HttpApplication.java(S2I) file and double-click to open it.
  3. Double-click on the left ruler column to set a breakpoint.

    crs os debugging breakpoint
  4. Open OpenShift Application Explorer.
  5. Expand your project.
  6. Expand your application.
  7. Right-click your componentDebug.

    crs os debug

    The Console view appears.

  8. In OpenShift Application Explorer, expand your component.
  9. Right-click your urlOpen in Browser.

    crc os open in browser

    The Confirm Perspective Switch window appears.

  10. Click Switch.

    The Debug Perspective window appears displaying the debugging process.