Chapter 1. Introduction

OpenShift is a cloud solution for your application server requirements. OpenShift is a cloud-based application platform for Java, Perl, PHP, Python, and Ruby applications. JBoss Developer Studio supports OpenShift deployments and this guide will show you how to connect, create and deploy applications with OpenShift, from your workbench.

Chapter 2. Creating an OpenShift Application

The OpenShift Application creation wizard is accessed through JBoss Central or by navigating to File → New → Other.

Figure 2.1. Selecting the OpenShift Application wizard

After clicking on the OpenShift Application link, the creation wizard will launch.

Figure 2.2. Input OpenShift credentials

If you have already signed up for an OpenShift account then you can input your Username and Password here and click the Next button. If validation is successful you will see the Setup OpenShift Application screen.

If you do not have an OpenShift account, you can create one through the link at the top of the wizard screen. This will open the OpenShift sign-up page within your workbench. Once you have created an account you will need to relaunch the OpenShift Application wizard and input your new username and password.

Note

If you have a local OpenShift Cloud instance you can choose to connect to it instead by either selecting it from the available defined connections in the Connection list, or by deselecting the Use default server option and specifying your own in the Server field.

Figure 2.3. Creating a domain

If you need to create a domain, type the name you wish to have into the Domain name field. You will also need to ensure your public SSH key is provided and listed within the SSH2 Preferences. If you are unsure, click the SSH2 keys wizard link. Click Finish to complete domain creation.

If you already have a domain name then you will not see the Domain Creation screen.

Note

If you ever wish to rename your domain, this can be done through the OpenShift Explorer.

Figure 2.4. Creating a new OpenShift application

Now ready to create your OpenShift application, you will need to specify a name, the platform type to deploy for, from the Type drop-down list, and the Gear profile to be used.

The Gear profile option concerns the amount of physical space that will be allocated for use by the application. If you are running a trial version of OpenShift only the smallGear profile will be available to you.

Note

No underscores or special characters are allowed in the application name.

You can also select to embed cartridges into your applicaiton. By embedding a cartridge, you allow your application the ability to use the associated technology. For example, embedding the mysql cartridge will grant your application the capability to use a MySQL database.

Figure 2.5. Application setup

Since you are creating a new project, leave the Create a new project checkbox ticked.

For easy interaction with the OpenShift server and your domain it is recommended that you leave the Create and setup a server for easy publishing checkbox ticked. Doing so will create an OpenShift server instance in the Servers view, upon completing the wizard.

Click the Next button to progress in the wizard.

Figure 2.6. Cloning settings

The final screen of the OpenShift application wizard specifies Cloning settings. Here you can set the properties for creating a local copy of your application. The Location and Remote name options will be set automatically, however, you are able to change these by deselecting the default option and specifying custom settings in the fields provided.

Click Finish to create the application and clone the Git repository.

The OpenShift application that you created through the wizard, will appear in your Project Explorer tab.

Figure 2.7. Project in Project Explorer

After the Git repository has been cloned, it will be available through the Git Repositories view. You can open it by navigating to Window → Show View → Other → Git → Git Repositories. With the Git Repositories option selected, click OK.

Figure 2.8. Project added to available Git repositories

The wizard has also created a server adapter that connects to your OpenShift service. In the Servers tab there will be an OpenShift server available that contains your application. Any changes you make locally to the application can be published to your OpenShift instance by right-clicking on the application under the server in the Servers view, and selecting Full Publish.

Figure 2.9. Publising your project through the server adapter

As with a local server, double-clicking on the OpenShift server instance in the Servers tab will open the server overview page in your workbench.

Figure 2.10. OpenShift server overview and settings

The OpenShift application will also be available under your domain in the OpenShift Explorer view.

Figure 2.11. OpenShift Explorer view

Chapter 3. Import an existing application

To import an existing OpenShift application to your workbench, from JBoss Central navigate to the Create Projects section and click on OpenShift Application.

On the Setup OpenShift Application screen click the checkbox beside Use existing application and click the Browse button.

Figure 3.3. Setup OpenShift Application screen

A dialog will open where you will see all your OpenShift applications listed, for the current domain.

Figure 3.4. Existing applications on OpenShift

By selecting an application from the list and clicking the Details button you can see all relevant application information. Click the OK to return to the application selection screen.

Figure 3.5. Details of OpenShift application

Select the application to import and click the OK button.

You will be returned to the Setup OpenShift Application screen and the Use existing application field will be populated with the name of the application you selected.

Figure 3.6. Setup OpenShift Application screen

To complete importing the application click the Next button and continue follow the instructions after the Setup OpenShift Application screen that are available in the Creating an OpenShift Application chapter: Figure 2.6, “Cloning settings”.

Open the pom.xml file of your web application in the editor by double-clicking on the file in your Project Explorer and selecting the pom.xml tab in your workbench.

Create profiles tags within the project tags of the pom.xml file. Within the profiles tags, press Ctrl and Spacebar together to trigger auto-completion.

From the auto-completion menu, select OpenShift profile. The profile information to connect to OpenShift will be inserted.

Figure 4.1. Selecting the OpenShift Profile

Chapter 5. Port Forwarding

Port forwarding is available for each OpenShift application. To access port forwarding for an application right-click on an application in the OpenShift Explorer view tab and select Port forwarding from the context menu.

Figure 5.1. Port forwarding option

The Application port forward dialog will display ports that can be forwarded. To forward all ports click the Start All and the Stop All button will stop port forwarding for all listed ports.

If you do not wish to use the remote port numbers selected by default, click the checkbox beside the Find free ports for all Services option.

The default local address is set to 127.0.0.1 and if the remote port is not available a random one will be generated. If your operating system supports it, you can uncheck Use 127.0.0.1 as the local address for all services and the local address will become the same as the remote address.

Figure 5.2. Port forwarding dialog

Chapter 6. Debugging

6.1. Viewing the Remote Console

Similar to when you are running a server locally, you are also able to see console output for your remote OpenShift server. To have this output displayed to you, right-click on your OpenShift application in the OpenShift view tab, and select Tail files.

Figure 6.1. Tailing OpenShift server files option

The dialog that opens allows you to modify the tail options. A default tail command will be present and you can always revert back to it by pressing the Reset button. Once you have completed setting the tail options you wish, click the Finish button.

Figure 6.2. Tailing OpenShift server files option

A new tab will open called Console and display the last 100 lines of the servers boot.log and server.log files. This Console tab will now tail the content of these files on the server, outputing any updates to you, as they occur.

Figure 6.3. Viewing OpenShift server console output

This information can be useful in ensuring processes are executing as expected.

6.2. Viewing Environment Variables

You are able to view the environment variables that an OpenShift application is utilizing and the current content of each variable. To have this output displayed to you right-click on your OpenShift server in the OpenShift view tab, and select Environment Variables.

Figure 6.4. Selecting the Environment Variables menu item

The output will appear in the Console view tab.

Figure 6.5. Viewing OpenShift application environment variables

This information can be useful in ensuring an application is receiving the correct environment variable values.

Chapter 7. Deleting applications and domains

This chapter explains how to remove applications and domains from OpenShift.

7.1. Deleting an application

Deleting an application will only remove it from the OpenShift server. The application and OpenShift server adapter will remain in your workbench.

To remove an application right-click on it in the OpenShift Explorer view tab and select Delete Application(s) from the context menu.

Figure 7.1. Delete Application(s) menu item

A dialog window will display asking you to confirm the action and alerting you that you will not be able to recover the application one it has been deleted. Click the OK button to delete the application.

Figure 7.2. Confirming application deletion

Once the application has been deleted you will notice that it has been removed from the list of applications available on your OpenShift server.

Figure 7.3. Application removed

7.2. Deleting a domain

To delete a domain right-click on your server connection in the OpenShift Explorer view tab and select Delete Domain from the context menu.

Figure 7.4. Delete Domain menu item

A dialog box will be displayed asking you to confirm domain deletion. As a domain can only be deleted if it has no applications associated with it, an option is available to Force applications deletion. By selecting this checkbox any applications still associated with the domain will be deleted and unrecoverable.

Warning

It is recommended that you remove applications individually before deleting a domain to ensure you have created a copy of any application data you wish to keep.

If you do not select the Force applications deletion option and the domain to be removed still has an application associated with it, domain deletion will fail.

Figure 7.5. Confirming domain deletion

Once the domain has been deleted the connection to OpenShift will remain, however the Delete Domain option will not be available from the context menu.