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 instructions 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
- Start CodeReady Studio.
Click
. The Show View window appears.
- Enter OpenShift in the search field.
- Select OpenShift Application Explorer.
Click
.The OpenShift Application Explorer view appears.
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
- Start CodeReady Studio.
- Open OpenShift Application Explorer.
Click Can’t connect to cluster. Click to login.
The Login window appears.
Paste your OpenShift API URL into the URL field.
For more information on accessing your cluster through OpenShift API URL, visit Red Hat OpenShift - Accessing your Services.
- Enter your username and password or token.
- Click .
5.2.1. Browser-based token retrieval
Alternatively to providing your username and password or token, you can use browser based token retrieval to log in to your OpenShift cluster. There are two login options, "Paste Login Command" and "Retrieve Token".
Use "Paste Login Command"
Paste your OpenShift API URL into the URL field.
For more information on accessing your cluster through OpenShift API URL, visit Red Hat OpenShift - Accessing your Services.
Visit the OpenShift Container Platform web UI.
- Click the drop-down menu in the top right corner.
- Click Copy Login Command.
- Click Display Token.
- Copy the login command.
In the Sign in to OpenShift window, click .
Click
.NoteFor OpenShift 3, the login command is copied into your clipboard automatically.
Use "Retrieve Token"
Paste your OpenShift API URL into the URL field.
For more information on accessing your cluster through OpenShift API URL, visit Red Hat OpenShift - Accessing your Services.
Click
.- Enter your username and password.
- Click .
- Click .
- Click .
Your projects now appear in the OpenShift Application Explorer view.
5.3. Setting up a Developer Sandbox using OpenShift tools
The following section describes how to bootstrap and login to a Developer Sandbox in CodeReady Studio.
Procedure
- Start CodeReady Studio.
Open OpenShift Application Explorer.
- Right-click your OpenShift connection.
Click Login.
The Sign in to OpenShift window appears.
- Click Red Hat Developer Sandbox.
Provide the credentials of your Red Hat account and click
.Your Developer Sandbox has been bootstrapped.
The Login to Red Hat Developer Sandbox window appears.
- Click .
- Click .
- Provide the credentials of your Red Hat account again and click .
- Click Display Token.
Click Finish.
Your Token is displayed in the Sign in to OpenShift window.
Click
.You are now logged in to your Developer Sandbox.
Your Developer Sandbox shows in the OpenShift Application Explorer view.
5.4. 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.4.1. Creating an empty project
The following section describes how to create an empty project in CodeReady Studio.
Procedure
- Start CodeReady Studio.
Press Ctrl+N.
The Select a wizard window appears.
-
Select
. Click
.The New Project window appears.
- Name your project.
- Select the location for your project.
- Click .
Your newly created empty project is now listed in the Project Explorer view.
5.4.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
- Start CodeReady Studio.
- Start OpenShift Application Explorer.
Right-click any place in
. The New project window appears.
- Name your project.
- Click .
Your newly created project is now listed in the OpenShift Application Explorer view.
5.4.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
- Start CodeReady Studio.
- Start OpenShift Application Explorer.
Right-click the target
. The Create component window appears.
- Name your project.
- Click Eclipse Project. to select your
-
Set your Component type to
java-vertx
. -
Set the Project starter to
java-vertx
. - Name your application.
- Clear the Push after create check box.
- Click .
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.4. Devfile registry management using OpenShift Application Explorer
The following section describes how to create, delete, and edit devfile registries using OpenShift Application Explorer in CodeReady Studio.
Adding a devfile registry
- Start CodeReady Studio.
- Start OpenShift Application Explorer.
Devfile registries are displayed under the Devfile registries node.
If you expand the devfile registry node, all devfiles of that registry are shown.
To add a new devfile registry, right-click Devfile registries and click new.
The Create devfile registry window appears.
- Name your devfile registry.
- Paste your devfile URL.
- Click .
Your newly created devfile registry is now listed in the OpenShift Application Explorer view under Devfile registries.
Deleting a devfile registry
- Start CodeReady Studio.
- Start OpenShift Application Explorer.
Devfile registries are displayed under the Devfile registries node.
An expanded devfile registry node shows all devfiles of that registry.
To delete a devfile registry, right click the node of a devfile registry and click delete.
Your devfile registry is now deleted.
Editing a devfile registry
- To edit a devfile registry, use the YAML editor. The YAML editor provides syntax validation and content assist.
Additional resources
For further information on devfiles, visit Introduction to Devfile.
5.5. 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.5.1. Creating a launcher project
The following section describes how to create a launcher project in CodeReady Studio.
Procedure
- Start CodeReady Studio.
Press Ctrl+N.
The Select a wizard window appears.
- Enter Launcher in the search field.
- Select Launcher project.
Click
.The New Launcher project window appears.
-
Set Mission to
rest-http
. -
Set Runtime to
vert.x community
. - Name your project.
- Select the location for your project.
Click
.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.5.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
Right-click any place in
. The New project window appears.
- Name your project.
- Click .
Your newly created project is now listed in the OpenShift Application Explorer view.
5.5.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
- Start CodeReady Studio.
- Start OpenShift Application Explorer.
Right-click the target
. The Create component window appears.
- Name your project.
- Click Eclipse Project. to select your
-
Click on the arrow next to
S2I
and set your Component type tojava
. -
Set the Component version to
latest
. - Name your application.
- Clear the Push after create check box.
- Click .
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.6. 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
- Start CodeReady Studio.
- Start OpenShift Application Explorer.
- Expand your project.
- Expand your application.
Right-click your
. The Console view appears, displaying the process of file synchronization.
5.7. 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
- Start CodeReady Studio.
- Start OpenShift Application Explorer.
- Expand your project.
- Expand your application.
Right-click your
. The Create URL window appears.
- Name your URL.
- Set the Port value to 8080.
Click
.The Console view appears, displaying the process of URL creation.
In OpenShift Application Explorer, right-click your
. 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.8. 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
- Start CodeReady Studio.
-
In the Project Explorer view, locate the
MainVerticle.java
(devfiles) orHttpApplication.java
(S2I) file and double-click to open it. Double-click on the left ruler column to set a breakpoint.
- Open OpenShift Application Explorer.
- Expand your project.
- Expand your application.
Right-click your
. The Console view appears.
- In OpenShift Application Explorer, expand your component.
Right-click your
. The Confirm Perspective Switch window appears.
Click
.The Debug Perspective window appears displaying the debugging process.