cloud_foundry products Spring spring_boot

Cloud Foundry Eclipse 1.6.0: Spring Boot Support and Self-Signed Certificates

 

featured-eclipseCloud Foundry Eclipse integrates Cloud Foundry server and application management into Eclipse and Spring Tool Suite (STS). You can push applications to a Cloud Foundry server via drag and drop from the Eclipse Project Explorer much in the same way as deploying to a local tomcat server. Application memory and instances can be scaled easily, and services created and bound to an application through drag and drop. A comprehensive description of the plug-in is available at:

http://docs.cloudfoundry.org/devguide/deploy-apps/sts.html

Since 1.5.0, we have been busy making CF Eclipse ready to better support new features in Cloud Foundry public and private servers.

Version 1.6.0 introduces additional enhancements:

  1. Support for Spring Boot applications.
  2. Creating server instances to private clouds that use self-signed certificates.
  3. Environment variables for applications.
  4. Open memory configuration for applications.
  5. Comprehensive console output.

In this article we will cover these new features through an example where a Spring Boot application is deployed to a private Cloud Foundry server.

Installation

Spring Tool Suite 3.4.0 or higher integrates with Spring Boot. This allows you to create various types of Spring Boot projects like web, batch, and AMQP. Further reading can be found at:

http://docs.spring.io/sts/nan/v340/NewAndNoteworthy.html

In order to use the Spring Boot integration for STS, install Cloud Foundry Eclipse 1.6.0 into STS 3.4.0 or higher following these instructions:

http://docs.cloudfoundry.org/devguide/deploy-apps/sts.html#install-to-eclipse

Creating a Cloud Foundry Server Instance

Once Cloud Foundry Eclipse 1.6.0 has been installed, open the Servers view in STS/Eclipse, and create a new server instance. This can be done by right-clicking on the view to open the context menu and selecting:

New -> Server

server_newserver

In the first page, select “Cloud Foundry” under “Pivotal”, and click “Next” to open “Cloud Foundry Account”. Click on “Manage Cloud…” to add the URL to the private cloud.

server_wizard

Click “Add” and enter a name and URL for the private cloud.

server_manage_cloud_URLs

server_private_cloud_URL

After clicking “Finish”, a warning may appear indicating that the URL failed to validate. Click “Yes” to keep the URL. This will return to the “Manage Cloud URLs” dialogue.

server_unable_to_authenticate_URL

Click “OK” in the “Manage Cloud URLs” dialogue to return to the credentials page. Enter a username and password and click “Finish”, which will validate the credentials as well as automatically select the first organization and space that it finds as the server’s target space. Alternately, click “Next” to select another organization and space.

While validating the credentials, by clicking on “Finish”, “Next” or “Validate Account”, a confirmation dialogue is displayed showing that the server uses self-signed certificates, and whether to proceed in creating the server instance. If you select “Yes”, the Cloud Foundry Eclipse plug-in will remember the decision for any future server instance creation to this URL, and you will not be prompted again.

self-signed-cert

Once the server instance is successfully created, it will appear in the Servers view.

Creating and Configuring Spring Boot App

Now we create a Spring Boot application. Right-click on the Project Explorer and select:

New -> Spring Starter Project

This opens the Spring Boot (Starter) Project creation wizard. Enter details and the Spring Boot application type, and click “Finish”.

create_spring_boot_app_1

create_spring_boot_app_2

Once the project is created and built in the STS workspace, right-click on it and select:

Configure -> Enable as Cloud Foundry App

configure_spring_boot_CF

This step is necessary and allows the project to be deployable to a Cloud Foundry server instance in STS.

NOTE: As of version 1.6.0, this configuration only applies to Java Spring Boot applications, that is, Spring Boot applications that are packaged and deployed as jar files.

Pushing the Spring Boot Application

Once configured, you can simply drag and drop the Spring Boot project onto the private cloud in the Servers view.

This opens the Application Deployment wizard. You can click “Finish” right away, or “Next” to further configure the application. For instance, you can modify the mapped application URL, memory (default is set to 512MB), bind services, or set environment variables.

spring_boot_wizard_1

For our case, we click “Next”, and modify the memory.

spring_boot_wizard_2

Version 1.6.0 now supports open, variable memory configuration. Whereas previous versions of the plug-in restricted the memory choices, you can now enter any MB value over 0 up to your maximum allowed allocation. We change the default 512MB to 437MB.

spring_boot_wizard_2memorychange

Clicking “Next” will allow you to bind services, and a further click on “Next” opens the Environment Variables page, which is another new feature in version 1.6.0.

spring_boot_wizard_env_1

To add a new environment variable, right-click on the table to open the context menu and select “Add”. In our example we enter a RECAPTCHA_PRIVATE_KEY environment variable.

spring_boot_wizard_env_2

spring_boot_wizard_env_3

Click “Finish” to push the application to the Cloud Foundry server.

Application Staging and Console Output

Once the application begins deployment, the Eclipse console will automatically open and show progress during different stages of the deployment.

Version 1.6.0 introduces more comprehensive console progress than previous versions of the plug-in, displaying completed stages of the application deployment and start process.

console_staging

After the Spring Boot application completes staging and has successfully started, the console will display the application’s standard out and error logs.

console_staging_2

While the application is running, at any time you can refresh the console output by right-clicking on the application in the Servers view and selecting “Show Console”. This will only show the application’s standard out and error log files.

show_console

show_console_2

Editing Environment Variables and Memory

To edit application environment variables and memory, double-click on the application in the Servers view. This will open the Cloud Foundry server editor, and display bound services and instance stats for the application. The “General (Application Restart Required)” section allows environment variables and memory to be adjusted. For these changes to take effect, the application has to be restarted, which can be done directly from the Cloud Foundry server editor by clicking on either “Restart” or “Update and Restart”.

cf_editor

Improved Application Deployment

With version 1.6.0, we have enhanced application deployment from Eclipse-based IDEs. Pushing applications to private servers that use self-signed certificates is now possible. Furthermore you can now easily push Spring Boot projects to Cloud Foundry servers via drag and drop, much like any other web project.

We continue to further enhance the Cloud Foundry experience in Eclipse and STS in each new release of the plug-in.