Service Management Through Cloud Foundry Eclipse

October 16, 2014 Nieraj Singh

featured-CF-eclipseThe latest version of the Cloud Foundry Eclipse plug-in contains various enhancements for managing services in Cloud Foundry. Cloud Foundry Eclipse is a joint collaboration between Pivotal Software and IBM. Version 1.7.2 of the plug-in contains an updated UI that improves Cloud service management in Eclipse. In this article, we will cover service management for a Pivotal Web Services (PWS) server instance using the new UI.

We first start by showing how to install Cloud Foundry Eclipse and create a server instance to PWS. We then show how to create service instances and bind them to an application. Finally, we show how to unbind a service instance from an application and delete it.

Setting Up

Those new to Cloud Foundry can find additional information on Cloud services and service instances here. In Cloud Foundry Eclipse, service management specifically refers to service instances.

Installing Cloud Foundry Eclipse

Cloud Foundry Eclipse can be installed either into Spring Tool Suite (STS) or Eclipse JEE from the STS dashboard or the Eclipse Marketplace. For this article, we use STS.

Java 7 is now a minimum required execution environment for Cloud Foundry Eclipse.

To install Cloud Foundry Eclipse, please follow one of the installation instructions here. Cloud Foundry Eclipse can also be installed in offline mode.

Creating a Server Instance

Account registration for PWS can be found here, and it is required prior to creating a PWS server instance through Cloud Foundry Eclipse.

Before Cloud services can be managed through Eclipse, a Cloud Foundry server instance must be created. Cloud Foundry Eclipse is integrated into the Eclipse Web Tools Platform, and a server instance can easily be created through the Eclipse New Server wizard.

Following the instructions in the link above, we will first create a server instance to a PWS organization and space, which then appears in the Eclipse Servers view as “Pivotal Cloud Foundry”.

c172_servers_view

We will use this server instance to show how service instances can be added to our space, bound and unbound to an application, and deleted.

Creating a Service

Services are managed and created through the Cloud Foundry server editor. To create a service instance, we first double-click on our server in the Eclipse Servers view to open the editor, and then navigate to the Applications and Services tab.

cf172_server_editor

In Applications and Services, services are managed in a Services section on the bottom left of the editor, shown in the screenshot below. This section shows all the service instances that are currently created in the server’s space. Service instances can be created, deleted and bound to applications from this section. To create a service instance, we click on a toolbar button on the top right corner of the Services section to open the Add Service wizard, as highlighted in red below.

cf172_editor

The UI for the Add Service wizard has changed substantially from previous versions of the plug-in. In the latest version, all available services in the space are shown in a scrollable list for easier browsing.

cf172_editor_create_services

A filter control allows this list to be narrowed down by patterns matched to service names or descriptions. In our case, we want to filter out all services except those that match “sql”. In PWS, the list is reduced to two entries: MySQL (cleardb) and PostgreSQL (elephantsql).

cf172_editor_create_services_filter

We then select elephantsql from the list. A service instance name and plan, shown at the bottom of the wizard, must be specified before the wizard can complete. Each service selection in the list populates the instance name and plan with default values. However, we can also set our own name and choose a different plan. In our case, we change the default name to “cfeclipsepqsl” and keep the default plan.

cf172_editor_create_services_plan

We then finish the wizard to create the service instance, and it now appears in the Services section.

cf172_editor_created_service

Binding Services

Certain service instances can be bound to applications either when the application is first deployed to Cloud Foundry, or any time afterward through the Cloud Foundry server editor.

Binding a Service During Deployment

To bind a service instance to an application during deployment, we first push an application to our Cloud Foundry server. For this example, we create a Spring Boot application called “pwsspringbootweb” through the STS Spring Starter wizard, which is available in STS version 3.4.0 or higher.

Once created, we need to configure the Spring Boot application for deployment to the Cloud Foundry server. In the Eclipse Package or Project Explorer, we right-click on the Spring Boot project and select Configure -> Enable as Cloud Foundry App in the context menu.

cf172_enable_as_cf

Now we drag and drop the project from the Package or Project Explorer into the Applications section in the editor. Alternatively, we can also right-click on the project in the Package or Project Explorer and select Run As -> Run on Server in the context menu, and choose our Cloud Foundry server instance, “Pivotal Cloud Foundry”, from the list of servers.

cf172_app_drag_drop

Either application deployment approach opens the Application Deployment wizard.

cf172_app_deployment

We enter the deployment details for the application in the first two pages, like the application name, memory and URL, and click “Next” until the Services Selection page is displayed.

cf172_app_deployment_services

This page allows us to both create new service instances and bind existing or new ones to the application.

To add a new service instance and bind it to the application, we click on the Add Service button in the top right toolbar as shown above, which displays the same Add Service wizard opened earlier from the editor. We create a “rediscloud” service, and once it appears in the Services Selection list, it will by default be checked for binding.

Binding services through the Application Deployment wizard is optional. Only checked services in the Services Selection list will be bound to the application, and any of the services can be unchecked. In our case we do not check any further services to bind except for “rediscloud”.

cf172_app_deployment_created_service

Clicking “Finish” deploys the application, and after it has been successfully pushed to the Cloud Foundry server, it appears both in the Eclipse Servers view and the editor.

cf172_app_deployment_editor

The screenshot above shows the deployed application on the left side of the editor. Selecting the application then shows additional UI on the right side that displays further application details, including an Application Services section. This section lists all the bound service instances for the application, which in our case is the “rediscloud” service that we created and bound earlier during the application deployment phase.

Binding Additional Services

Previously, we had also created another service instance called “cfeclipsepqsl”. We now would like to bind this service to our Spring Boot application. There are two approaches to bind further services to an existing application:

1. Drag and Drop

cf172_app_editor_drag_drop_binding

Drag and drop the service instance from the Services section on the left side into the Application Services section on the right, as shown above.

2. Manage Service Bindings Wizard

cf172_app_manage_bindings

Introduced in version 1.7.2 of the plug-in to improve user accessibility and provide an alternative for binding a service, services can now also be bound to applications through a context menu on a service selection in the Services section.

We will use this approach to bind “cfeclipsepqsl” to our application. We select “cfeclipsepqsl” in the Services section and right-click to select Manage Service Bindings from the context menu. This opens the Manage Service Bindings wizard where we see a list of all the deployed applications in the space.

cf172_app_manage_bindings_2

We now select which applications we want “cfeclipsepsql” to be bound with. As we only have one application deployed in our space, namely “pwsspringbootweb”, we select this application and click “Finish”.

The service instance is then bound to the application and will appear in the Application Services section.

Unbinding a Service

Unbinding services can easily be done in the Application Services section for an application. We right-click on a bound service instance in Application Services and choose Unbind from Application in the context menu, which unbinds the service and removes it from the list of bound services.

cf172_app_unbind_service

Deleting a Service

Finally, we show how to delete a service instance from a space. In the Applications and Services tab in the editor, we select a service instance in the Services section and simply right-click on it and choose Delete from the context menu.

cf172_delete_service

This deletes the service instancce, as well as automatically unbinds it from any application in the space that uses this service.

About the Author

Biography

More Content by Nieraj Singh
Previous
Getting to Zero: Strategizing a Validation Process with Mobilise
Getting to Zero: Strategizing a Validation Process with Mobilise

How do you get started? This was a question that was being asked on both sides of the table at Pivotal Labs...

Next
Big Data Suite Gets Big Props From Customers, Partners
Big Data Suite Gets Big Props From Customers, Partners

Just over 6 months after launching Pivotal Big Data Suite (BDS), Pivotal customers and partners are rallyin...

Enter curious. Exit smarter.

Learn More