JBoss.orgCommunity Documentation

Chapter 8. OpenShift Tools

8.1. Overview of OpenShift Tools
8.1.1. About OpenShift
8.1.2. About OpenShift Tools
8.2. Features of OpenShift Tools
8.2.1. Features Overview
8.2.2. Create an OpenShift Online User Account
8.2.3. Connect to OpenShift
8.2.4. Manage a Connection
8.2.5. Generate and Upload SSH Keys to OpenShift
8.2.6. Manage SSH Keys
8.2.7. Create a Domain
8.2.8. Manage a Domain
8.2.9. Deploy a New or Existing Application on OpenShift
8.2.10. Import a Deployed OpenShift Application into the IDE
8.2.11. Generate a Server Adapter for an Application
8.2.12. View a Deployed Application and Associated Information
8.2.13. Manage a Deployed Application
8.2.14. Debug a Deployed Application
8.3. Customizing OpenShift Tools
8.3.1. Customizing Overview
8.3.2. Change the Timeout Behavior of OpenShift Requests

OpenShift is Red Hat's Platform as a Service (PaaS) for applications. It consists of an application platform in the cloud, enabling you to build, test and run applications in a cloud architecture. OpenShift provides disk space, CPU resources, network connectivity, and a runtime environment.

OpenShift is available in three versions: OpenShift Online, Enterprise and Origin. OpenShift Online is the public cloud offering, with free and paid plans, hosted at https://openshift.redhat.com. OpenShift Enterprise is the private cloud offering, obtained through a Red Hat OpenShift subscription and hosted in a private data center. OpenShift Origin is the community and local cloud offering, available to download and install locally for development and testing purposes.

OpenShift has a number of key features to assist you in developing and deploying applications:

  • Unique domain names, or namespaces, support the hosting of your applications. A user account provides you with access to domains, the latter having the potential to be associated with multiple applications.

  • Numerous cartridges give you access to predefined build and runtime environments with popular languages, database and management frameworks. OpenShift can also be extensively customized with the Do-It-Yourself (DIY) cartridge.

  • Different sized gears provide RAM and disk space for your applications and cartridges. You can use a set number of small gears as part of OpenShift Online with Free Plan, a free OpenShift user account, and extend to more gears and bigger gears with OpenShift Online with Silver Plan or OpenShift Enterprise.

  • Built-in administrative and stack management frees you up to focus on code development. OpenShift manages the intricate details of deploying your application to the stack and interfacing with middleware technologies for you.

  • Automatic or manual scaling of the resources supporting your applications ensures that application performance does not suffer as usage increases. OpenShift can create additional instances of your application across more gears and enable clustering.

OpenShift can be accessed via the web interface at https://www.openshift.com/ on the OpenShift website or via the OpenShift command line interface.

Once you have an OpenShift user account, you can connect to OpenShift and then create domains and applications. The procedure below guides you through connecting to OpenShift for the first time in the IDE.

Procedure 8.1. Connect to OpenShift

  1. In the OpenShift Explorer view, click the Connect to OpenShift icon .

  2. Complete the fields and options as detailed:


  3. Click Finish for OpenShift Tools to connect to OpenShift.

    1. If your credentials are incorrect, the Sign in to OpenShift wizard remains open for you to change your authentication information.

    2. If you selected for your password to be saved, you are prompted to enter your secure storage password or, if this is your first use of secure storage, you are prompted to set a secure storage password.

    Once your credentials are verified as correct, the wizard closes and a live OpenShift connection is listed in the OpenShift Explorer view.


When you close the IDE, any live OpenShift connections will be disconnected but they can be easily reestablished. OpenShift Tools lists previous connections in the OpenShift Explorer view until cleared by you. In the OpenShift Explorer view, double-click or expand the appropriate connection to open an automatically completed connection wizard. Type your password or, if using the saved password facility, the master password and click Finish.

SSH keys are essential when working with OpenShift. They enable you to develop and access deployed applications. SSH keys are also used to control access of other contributors to your OpenShift applications. SSH keys must be uploaded to the OpenShift server and, as detailed in the procedure below, OpenShift Tools can assist with both the generation and uploading of SSH keys to OpenShift.

Procedure 8.2. Generate and Upload SSH Keys to OpenShift

  1. In the OpenShift Explorer view, right-click the connection and click Manage SSH Keys.

  2. To create a new SSH private-public key pair, click New.

  3. Complete the fields and options as detailed:

    • In the Name field, type a name for the key pair that will be used by OpenShift to distinguish this key pair from others associated with your account.

    • From the Key Type list, select SSH_RSA.

    • Ensure the SSH2 Home field contains the location where you want to create the files associated with the key pair. To change the location, clear the Default check box and click Browse to navigate to the desired location.

      Note

      The default location for creating SSH key files is determined by the SSH information for the IDE. The default location can be altered by clicking WindowsPreferences, expanding GeneralNetwork Connections, selecting SSH2 and changing the location in the SSH2 home field of the General tab.

    • In the Private Key File Name field, type a name for the private key file.

    • In the Private Key Passphrase field, type a passphrase for use in accessing the private key. This field is not mandatory and can be left empty if you want.

    • In the Public Key File Name field, type a name for the public key file. Typically the file name of the public key is that of the private key with .pub appended.


  4. Click Finish. The SSH key pair is generated and the public key automatically uploaded to OpenShift.

  5. Click OK to close the Manage SSH Keys window.

OpenShift Tools provides actions for managing the SSH keys of your OpenShift account.

Upload an existing public SSH key to OpenShift

In the OpenShift Explorer view, right-click the connection and click Manage SSH Keys. Click Add Existing. In the Name field, type a name for the key that will be used by OpenShift to distinguish the key from others associated with your account. Click Browse to navigate to and select the public key file. Click Finish and click OK to close the Manage SSH Keys window.

You must also inform the IDE of the location of the private key file. Click WindowPreferences, expand GeneralNetwork Connections and selecting SSH2. Click Add Private Key and locate the private key file. Click Apply and click OK to close the Preferences window.

Remove a public SSH key from OpenShift

In the OpenShift Explorer view, right-click the connection and click Manage SSH Keys. From the SSH Public Keys table select the key you want to remove from your OpenShift account and click Remove. At the prompt asking if you are sure you want to remove the key, click OK. Click OK to close the Manage SSH Keys window.

Refresh the SSH key information associated with OpenShift

In the OpenShift Explorer view, right-click the connection and click Manage SSH Keys. Click Refresh and click OK to close the Manage SSH Keys window. It may be necessary to use this action if you make changes to your OpenShift SSH key settings through the OpenShift web interface while the IDE is open with a live OpenShift connection.

OpenShift Tools provides actions for managing the domains of your OpenShift account.

OpenShift Tools provides the OpenShift Application wizard to assist you in creating and deploying OpenShift applications.

As detailed in the procedure below, OpenShift applications can be created using three sources: an existing workspace project, a Git source or a default project template. For an existing workspace project, the wizard merges the existing project contents with the key metadata files from a new OpenShift application so that the application can be deployed on OpenShift. For a Git source, the wizard uses the source as the new OpenShift application so the source must be OpenShift-enabled, namely have a .openshift directory and have the openshift profile specified in the pom.xml. For a project template, the templates are provided by OpenShift.

In addition to deploying your OpenShift applications, the wizard assists you in setting up linked remote (OpenShift server) and local Git repositories containing the original and clone of your project, respectively. You can then push project changes to OpenShift via Git or allow the OpenShift server adapter to do it for you.

Procedure 8.4. Create and Deploy an Application on OpenShift

  1. In the OpenShift Explorer view, right-click the connection or domain and click NewApplication. Alternatively, in JBoss Central click OpenShift Application, after which you are prompted to select an OpenShift connection and provide your user authentication information.


  2. If you do not have a domain associated with the connection, the wizard prompts you to create one. In the Domain Name field, type the name of the domain you would like to use and click Finish. Domain names must be unique so if the name you have chosen is already in use you will see a warning. In this case, choose another name and try again until you have a unique one.

  3. Complete the fields and options about the OpenShift application as detailed:


  4. Click Next.

  5. Complete the fields and options as detailed:

  6. Click Next.

  7. The Git Clone Destination field shows the location to be used for the local Git repository. The location must already exist to be able to proceed with the wizard. To change the location, clear the Use default clone location check box and type the location in the Git Clone Destination field or click Browse to navigate to the location.


  8. Click Finish. If you are prompted that the authenticity of the host cannot be established and asked whether you want to continue connecting, check that the host name matches that of your application and domain and click Yes.

  9. At the prompt asking if you want to publish committed changes to OpenShift, click Yes. The progress of the application creation process is visible in the Console view.

Once created, the application is listed under the connection and domain in the OpenShift Explorer view. The application type proceeds the application name. The project is also listed in the Project Explorer and Git Repositories views, where the details proceeding the application name indicate the current Git branch and status compared to the remote repository. Additionally, the server adapter for the application is visible in the Servers view.

All applications deployed on OpenShift are listed under live connections in the OpenShift Explorer view. But only the project files of OpenShift applications created through the IDE are immediately available in the Project Explorer and Git Repositories views. If you want to work on the project files associated with an application, you must first import the application. OpenShift Tools can assist you to import your deployed OpenShift applications into the IDE, as detailed in the procedure below.

Procedure 8.5. Import an OpenShift Application

  1. Click FileImport, expand OpenShift and double-click Existing OpenShift Application. Alternatively, in the OpenShift Explorer view, right-click the application and click Import Application.

  2. Complete the fields and options as detailed:

    • From the Domain list, select the domain of the application.

    • Ensure the Use existing application check box is selected and type the name of the application in the text field. This field has an automatic completion feature to assist you in typing the application name or click Browse to see a list of all of your applications associated with the domain.

      Important

      Project names in the IDE workspace must be unique. If the name of the application you want to import is identical to an existing project in the workspace, the OpenShift Tools will not complete the import. To work around this constraint, you can import the OpenShift application to another workspace or change the name of either the conflicting project or application.


  3. Click Next.

  4. Complete the fields and options as detailed:

  5. Click Next.

  6. The Git Clone Destination field shows the location to be used for the local Git repository. The location must already exist to be able to proceed with the wizard. To change the location, clear the Use default clone location check box and type the location in the Git Clone Destination field or click Browse to navigate to the location.

  7. Click Finish. If you are prompted that the authenticity of the host cannot be established and asked whether you want to continue connecting, check that the host name matches that of your application and domain and click Yes.

  8. OpenShift Tools modifies the .gitignore file on importing the application. At the prompt asking if you want to publish committed changes to OpenShift, click Yes. The progress of the import process is visible in the Console view.

Once imported, the project is listed in the Project Explorer and Git Repositories veiws, where the details proceeding the application name indicate the current Git branch and status compared to the remote repository. Additionally, the server adapter for the application is visible in the Servers view.

In order to easily publish changes to a deployed OpenShift application, each application needs a server adapter. The OpenShift Application wizard can automatically generate server adapters for new or imported OpenShift applications if you select the Create and set up a server for easy publishing check box. But OpenShift also provides an action to assist you in generating server adapters for OpenShift application that already exist in the IDE, as detailed in the procedure below. You can use this action if you need to regenerate a deleted server adapter for an OpenShift application or if you create or import an OpenShift application and do not select the Create and set up a server for easy publishing check box.

Procedure 8.6. Generate a server adapter for an application

  1. In the OpenShift Explorer view, right-click the application and click Create a Server Adapter.

  2. Complete the fields and options as detailed:

    • From the list of server types, expand OpenShift and select OpenShift Server.

    • The Server's host name and Server name field are automatically completed. The Server's host name field contains the host name of the server and the Server name field contains the name by which the server adapter is know in the Servers view. You can edit these values as appropriate by typing in the fields.


  3. Click Next.

  4. Complete the fields and options as detailed:


  5. Click Next.

  6. From the Available list, select the project for which the server adapter is being generated and click Add. The application is now listed under Configured.

  7. Click Finish for OpenShift Tools to generate the server adapter. Once generated, the server adapter is listed in the Servers view.


OpenShift Tools provides actions for viewing deployed OpenShift applications and information about them.

View a deployed application

In the OpenShift Explorer view, right-click the application and click Web Browser. A browser tab opens displaying your deployed application. Alternatively, in the Servers view, right-click the server adapter for the application and click Show InWeb Browser.

View information about an application

In the OpenShift Explorer view, right-click the application and click Details. The displayed information includes the public URL of the application, application type, and remote Git repository location. Click OK to close the Details window.


View output from the OpenShift server

In the OpenShift Explorer view, right-click the application and click Tail files. Alternatively, in the Servers view right-click the server adapter of the application and click OpenShiftTail files. The Tail Log Files window opens, with either the default retrieval syntax or last used syntax for this application in the Tail options field.

To change the retrieval command, in the Tail options field type the appropriate syntax. To specify the gears for which to show the server logs, from the table select the check boxes of the appropriate gears. Click Finish for OpenShift to retrieve the output, which is displayed in a distinct Console view for each gear.


View values of variables associated with an application

In the OpenShift Explorer view, right-click the application and click All Environment Variables. Variable names and values are listed in the Console view. Alternatively, in the Servers view, right-click the server adapter of the application and click OpenShiftAll Environment Variables.


View properties of cartridges associated with an application

In the OpenShift Explorer view, right-click the cartridge and click properties. The Properties view opens and lists information about the cartridge.

View information about the server of an application

In the Servers view, double-click the server adapter for the application. A Server Editor opens, enabling viewing and editing of server details. To save any changes, press Ctrl+S or click FileSave or click the Save icon.

Refresh information about an application

In the OpenShift Explorer view, right-click the connection, domain, application or cartridge and click Refresh. Information is retrieved from OpenShift and the OpenShift Explorer view is updated as appropriate. This action is useful if you are simultaneously making changes in the IDE and the OpenShift web interface or command line interface to your domain and applications. Additionally, it may be used to recover from errors.

OpenShift Tools provides actions for developing and managing deployed OpenShift applications.

Upload modifications to a deployed application

In the Servers view, right-click the server adapter for the application and click Publish. At the prompt asking if you want to publish to OpenShift by committing changes to Git, you can customize the default commit message Commit from JBoss Tools. Click Yes and the changes, together with the commit message, are pushed to the remote Git repository. Additionally, the application is automatically updated on the OpenShift server and the Console view displays OpenShift server output.

Edit environment variables associated with an application

In the OpenShift Explorer view, right-click the application and click Edit Environment Variables. Click Add, Edit or Remove to customize the environment variables. Click Finish to close the window.

Add or remove markers associated with an application

In the Project Explorer view, right-click the application and click OpenShiftConfigure Markers. Select or clear the check boxes of markers as desired. Information about markers is given in the Marker Description section of the Configure OpenShift Markers Window. Click OK for your marker choice to be applied to the application.


Add or remove cartridges associated with an application

In the OpenShift Explorer view, right-click the application and click Edit Embedded Cartridges. Select or clear the check boxes of cartridges as desired. Click Finish for your cartridge choice to be applied to the application. You are prompted if the cartridges you have chosen to add or remove require further action, such as the addition of prerequisite cartridges or removal of conflicting cartridges. You can choose to ignore or apply the suggestions of the prompt.


Restart an application

In the OpenShift Explorer view, right-click the application and click Restart Application. Alternatively, in the Servers tab right-click the server adapter of the application and click OpenShiftRestart Application.

Forward remote ports

You can forward the remote ports of the OpenShift server to your system to enable access to various services, such as MySQL. Port forwarding is available for all OpenShift applications, including scalable ones.

In the OpenShift Explorer view, right-click the application and click Port forwarding. Alternatively, in the Servers view right-click the server adapter of the application and click OpenShiftPort forwarding.


After checking the authenticity of SSH keys, the Application port forward window opens. Before commencing port forwarding, there are a number of options you can set:

  • By default, the local address is 127.0.0.1. If this is unavailable, a random available address is allocated. To set the local address to be the same as the remote address, clear the Use '127.0.0.1' as the local address for all Services check box.

  • By default, the local port numbers are the same as the remote port numbers. To set independent local port numbers, select the Find free ports for all Services check box.

To commence port forwarding, click Start All. Click OK to close the Application port forward window.

Delete a server adapter for an OpenShift application

In the Servers view, right-click the server adapter for the application and click Delete. At the prompt asking if you are sure you want to delete the server adapter, click OK.

Delete an application

In the OpenShift Explorer view, right-click the application and click Delete Application. At the prompt asking if you are sure you want to destroy the application, select OK. The progress of the deleting process is shown in the activity bar in the lower right of the IDE window. To open the Progress view and see more detailed progress information or cancel the deleting process, double-click on the activity bar.

OpenShift Tools enables you to debug your deployed OpenShift applications within the IDE through port forwarding. A number of configuration steps are required both locally and remotely to achieve this. You must first set the Enable JPDA (Java Platform Debugger Architecture) marker in your application source code that configures the virtual machine running the server on which your application is deployed for debugging. You must then configure port forwarding for the local and remote debug ports and connect the IDE debugger. The procedures below guide you through each of these configuration requirements and must be completed in the order given.