Working with user-provided services in Cloud Foundry Enterprise Environment

Cloud Foundry Enterprise Environment provides a mechanism for you to connect and use User-Provided services, which are services that might not be provided by or available in your cloud environment.

Introduction

To use a user-provided service with your application, you need the following accounts and tools:

With user-provided services in Cloud Foundry, you can bind your applications to services outside of your IBM Cloud Private environment's marketplace by using the Liberty for Java™, SDK for Node.js, Runtime for Swift, or ASP.NET Core buildpacks.

How to use the guides

The following procedure gives the general process for you to create an external service, deploy your application, and bind your application to your external service by using the Cloud Foundry buildpacks. If you have the service credentials, you can adapt this procedure for your own applications and any service that is hosted in a public cloud or IBM Cloud Private to make a user-provided service. Cloud Foundry provides you with options for creating your service and providing credentials for it. For more information about how to customize user-provided services for your cloud environment, see the Cloud Foundry documentation on User-provided service instances External link icon.

You can also use the starter applications for Liberty or Node.js, which provide specific examples of setting up user-provided services in a cloud environment. The procedures show how to create a user-provided service with a starter application and a Cloudant® NoSQL DB service in IBM Cloud.

Before you begin

Tip: If you are working without external Internet access, read through the procedure completely before you start working with buildpacks. Ensure that you have access to all the necessary documentation and resources.

Step 1: Create an external service

You can bind to any service outside of your environment if you have the necessary credentials. For example, you can create a service instance in IBM Cloud, then deploy an application in Cloud Foundry Enterprise Environment that binds to your IBM Cloud service.

Step 2: Save your service credentials

After you create your service instance, save the credentials that you need to bind your application. You can save these credentials in a JSON file. While different services might have specific credential requirements and formats, the following example template shows the credentials you need for a Cloudant NoSQL DB.

{
  "username": "<username>",
  "password": "<password>",
  "host": "<host.dns.name>",
  "port": <port>,
  "url": "https://<username>:<password>@<host.dns.name>"
}

Step 3: Create a user-provided service

You can use the Cloud Foundry cf cups command to create a user-provided service.

cf create-user-provided service <service name> -p <path to JSON file>

Note: Cloud Foundry provides information about other methods to create user-provided services that you can access from the command line by using the cf create-user-provided-service command.

Step 4: Bind your application to a user-provided service

Bind the user-provided service to the application by using the command line.

cf bind-service <app-name> <service-name>

Next, restage your application.

cf restage <app-name>

After restaging, you can confirm that your application works as you expect by browsing to your application's URL. Or, you can use the cf service command to view the services and bound applications.

User-provided services examples and information in Cloud Foundry Enterprise Environment

The buildpack starter applications guide you through creating a user-provided service, creating a Cloudant database in IBM Cloud, and binding an application to your service.

Try creating user-provided services and binding applications: