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 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. Create and Deploy an Application on OpenShift
8.2.10. Deploy an Existing Application on OpenShift
8.2.11. Import a Deployed OpenShift Application into the IDE
8.2.12. Generate a server adapter for an application
8.2.13. View a Deployed Application and Associated Information
8.2.14. Manage a Deployed Application

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 has a number of key features to assist you in developing and deploying applications:

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 a domain and applications. The procedure below guides you through setting up a connection to OpenShift using your user account information.

Procedure 8.1. Connect to OpenShift

  1. Click the OpenShift Explorer tab and click the Connect to OpenShift icon .

  2. From the Connection list, select New Connection.


  3. If you want to use a server other than the default at https://openshift.redhat.com, clear the Use default server check box and in the Server field type the address of the server.

    Note

    There are a number of OpenShift servers from which you can choose:

  4. In the Username and Password fields, type your OpenShift user account authentication information.

  5. If you want the Password field to automatically populate for this connection in future, select the Save password check box.

    Note

    The password is retained in secure storage provided by the IDE. To manage the settings for secure storage, click WindowPreferences, expand GeneralSecurity and select Secure Storage.

  6. 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 tab.


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 tab until cleared by you. In the OpenShift Explorer tab, double-click or expand the appropriate connection to open an automatically completed connection wizard. Type your password or the master password, if using the saved password facility, 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 tab, right-click the connection and click Manage SSH Keys.

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

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


  4. From the Key Type list, select SSH_RSA.

  5. 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 type the location in the SSH2 Home field or click Browse to navigate to the desired location.

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

  7. 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.

  8. 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.

  9. Click Finish. The SSH key pair will be generated and the public key automatically uploaded to OpenShift.

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

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

OpenShift Tools provides the OpenShift Application wizard to assist you in creating new applications and deploying them on OpenShift. OpenShift uses Git, a free and open source version control system. The wizard will also assist you in setting up linked remote and local Git repositories containing the original and clone of your project, respectively. To create an application, you must have a domain and, in the case that you do not have a domain already set up, the wizard will prompt and guide you in creating one first. The procedure below guides you through using the OpenShift Application wizard.

Procedure 8.4. Create and Deploy an Application on OpenShift

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


  2. In the Name field, type a name for the new OpenShift application.


  3. From the Type list, select a runtime server. This will ensure the necessary core programming or technology cartridge is added to your application.

  4. From the Gear profile list, select the gear size. This is RAM and disk space required by your applications and its cartridges. If you are using OpenShift Online with Free Plan, you have access to small gears only.

  5. If you want OpenShift to automatically increase the instances of your application and enable clustering as usage increases, select the Enable scaling check box.

  6. From the Embedded Cartridges list, select the functionality you want to enable in your application. This will add associated capabilities and support to your application.

  7. To specify that the new application is to be based on source code from an existing Git repository, click Advanced and clear the Use default source code check box. In the Source code field, type the URL of the source code location. OpenShift clones the source code to the OpenShift git repository for your application, instead of using the default template.

  8. Click Next.

  9. Ensure the Create a new project and Create and set up a server for easy publishing check boxes are selected. The latter will automatically create an OpenShift server adapter for the application, enabling you to easily upload changes to the OpenShift server.

  10. To disable Maven builds, check the Disable automatic Maven builds when pushing to OpenShift check box. This informs OpenShift not to launch the Maven build process when the Maven project is pushed to OpenShift but to put the deployment straight into the deployments folder. It is useful when you want to push applications already built for deployment rather than source code.

  11. Click Next.

  12. The Location field shows the location that will 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 location check box and type the location in the Location field or click Browse to navigate to the desired location.


  13. 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.

  14. 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 tab.

Once created, the application is listed under the connection in the OpenShift Explorer tab. The application type proceeds the application name. The project is also listed in the Project Explorer and Git Repositories tabs, 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 tab.

OpenShift Tools can assist you to deploy existing workspace applications to OpenShift, as detailed in the procedure below. The procedure uses the OpenShift Application wizard, with the latter merging the existing project contents with the key metadata files from a new OpenShift application so that the application can be deployed on OpenShift. The wizard also enables git for the existing project, so that you can push project changes to OpenShift via git or allow the OpenShift Server Adapter do it for you.

Procedure 8.5. Deploy an Existing Application on OpenShift

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

  2. In the Name field, type a name for the new OpenShift application. For simplicity, you may choose this to be the same as the name of the workspace project.

    Note

    There are restrictions on the name you can use for an application. Names must consist only of letters and digits.

  3. From the Type list, select a runtime server. This will ensure the necessary core programming or technology cartridge is added to your application.

  4. From the Gear profile list, select the gear size. This is RAM and disk space required by your applications and its cartridges. If you are using OpenShift Online with Free Plan, you have access to small gears only.

  5. If you want OpenShift to automatically increase the instances of your application and enable clustering as usage increases, select the Enable scaling check box.

  6. From the Embedded Cartridges list, select the functionality you want to enable in your application. This will add associated capabilities and support to your application.

  7. To specify that the new application is to be based on source code from an existing Git repository, click Advanced and clear the Use default source code check box. In the Source code field, type the URL of the source code location. OpenShift clones the source code to the OpenShift git repository for your application, instead of using the default template.

  8. Click Next.

  9. Clear the Create a new project check box and in the Use existing project field type the name of the project or click Browse to locate the project.

  10. Ensure the Create and set up a server for easy publishing check box is selected. This option automatically creates an OpenShift server adapter for the application, enabling you to easily upload changes to the OpenShift server.

  11. To disable Maven builds, check the Disable automatic Maven builds when pushing to OpenShift check box. This informs OpenShift not to launch the Maven build process when the Maven project is pushed to OpenShift but to put the deployment straight into the deployments folder. It is useful when you want to push applications already built for deployment rather than source code.

  12. Click Next.

  13. The Location field shows the location that will 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 location check box and type the location in the Location field or click Browse to navigate to the desired location.

  14. 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.

  15. 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 tab.

All applications deployed on OpenShift are listed under live connections in the OpenShift Explorer tab. But only the project files of OpenShift applications created through the IDE will be immediately available in the Project Explorer and Git Repositories tabs. 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.6. Import an OpenShift Application

  1. Click FileImport, expand OpenShift, select Existing OpenShift Application and click Next. Alternatively, in the OpenShift Explorer tab, right-click the application and click Import Application.

  2. Ensure the Use existing application check box is selected and type the name of the application in the text field. This field has an auto-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 connection.

    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 one of the conflicting projects and applications.


  3. Click Next.

  4. Ensure the Create a new project and Create and set up a server for easy publishing check boxes are selected. The latter will automatically create an OpenShift server adapter for the application, enabling you to easily upload changes to the OpenShift server.

  5. To disable Maven builds, check the Disable automatic Maven builds when pushing to OpenShift check box. This informs OpenShift not to launch the Maven build process when the Maven project is pushed to OpenShift but to put the deployment straight into the deployments folder. It is useful when you want to push applications already built for deployment rather than source code.

  6. Click Next.

  7. The Location field shows the location that will 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 location check box and type the location in the Location field or click Browse to navigate to the desired 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. OpenShift Tools modified 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 tab.

Once imported, the project is listed in the Project Explorer and Git Repositories tabs, 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 tab.

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.7. Generate a server adapter for an application

  1. In the OpenShift Explorer tab, expand the connection.

  2. Right-click the application name and click Create a Server Adapter.

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


  4. The Server's host name and Server name field are automatically completed but you can change the contents of both as you need. 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 tab.

  5. Once the fields are complete, click Next.

  6. Ensure the Connection, Application Name and Deploy Project fields contain the correct information relating to the application for which you want to generate the server adapter.


  7. In the Remote field, type the alias for the remote Git repository. For OpenShift applications created and imported by OpenShift Tools this is origin.

  8. In the Output Directory field, type the location where archived projects for deployment should be stored or click Browse to navigate to the desired location.

  9. Click Next.

  10. 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.

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


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

View a deployed application

In the OpenShift Explorer tab, expand the connection. Right-click the application name and click Web Browser. A browser tab will open displaying your deployed application. Alternatively, in the Servers tab, right-click the server adapter for the application and click Show InWeb Browser.

View information about an application

In the OpenShift Explorer tab, expand the connection. Right-click the application name 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 tab, expand the connection. Right-click the application name and click Tail files. Alternatively, right-click the server adapter of the application in the Servers tab and click OpenShiftTail files. The Tail Log Files window opens, with the default retrieval syntax in the Tail options field. To change the retrieval command, in the Tail options field type the appropriate syntax. Click Finish for OpenShift to retrieve the output, which is displayed in the Console tab.


View values of variables associated with an application

In the OpenShift Explorer tab, expand the connection. Right-click the application name and click Environment Variables. Variable names and values are listed in the Console tab. Alternatively, in the Servers tab, right-click the server adapter of the application and click OpenShiftEnvironment Variables.


View information about the server of an application

In the Servers tab, double-click the server adapter for the application. A Server Editor tab 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 tab, right-click the connection and click Refresh. Information is retrieved from OpenShift and the OpenShift Explorer tab 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 Severs tab, 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, click OK. The commit message Commit from JBoss Tools is automatically generated and changes are pushed to the remote Git repository. Additionally, the application is automatically updated on the OpenShift server and the Console tab displays OpenShift server output.

Add or remove markers associated with an application

In the Project Explorer tab, 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 tab, expand the connection. Right-click the application name 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.


View properties of cartridges associated with an application

In the OpenShift Explorer tab, expand the connection and the application. Right-click the cartridge and click properties. The Properties tab opens and lists information about the cartridge.

Restart an application

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

Forward remote ports

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

In the OpenShift Explorer tab, expand the connection. Right-click the application name and click Port forwarding. Alternatively, right-click the server adapter of the application in the Servers tab 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 will be 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 tab, 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. The progress of the deleting process is shown in the activity bar in the lower right of the IDE window. To open the Progress tab and view more detailed progress information or cancel the deleting process, double-click on the activity bar.

Delete an application

In the OpenShift Explorer tab, expand the connection. Right-click the application name and click Delete Application(s). At the prompt asking if you are sure you want to destroy the application, select OK.