How to create user provided service

1,190 views
Skip to first unread message

Chetana Rachappanavar

unread,
Jan 19, 2015, 2:48:54 AM1/19/15
to vcap...@cloudfoundry.org

Hi,

I want to create user provided service. Could you please guide me the documentation or sample project or project with which I can start developing service.

Any help on this would be more helpful.

Thanks,

Chetana

Dieu Cao

unread,
Jan 19, 2015, 3:03:46 AM1/19/15
to vcap...@cloudfoundry.org
You can find documentation on user provided services here:

Chetana Rachappanavar

unread,
Jan 19, 2015, 3:11:18 AM1/19/15
to vcap...@cloudfoundry.org
Hi Dieu Cao,
Thanks for the reply. I want to develop user provided service. The link you gave tells about how to create service instance of user provided service.

I want a documentation which explains, how we can accept the user provided credentials in code and puts in VCAP_Variables.

Thanks,
Chetana R

Dieu Cao

unread,
Jan 19, 2015, 3:24:40 AM1/19/15
to vcap...@cloudfoundry.org
When you bind the user provided service to the app, it will make the credentials available as part of VCAP_SERVICES. 
You can find examples of how to use VCAP_SERVICES, for Ruby [1] , for Java [2], for Node.js [3]

Chetana Rachappanavar

unread,
Jan 19, 2015, 5:09:50 AM1/19/15
to vcap...@cloudfoundry.org
Yeah, I know that we get VCAP_SERVICES when we bind the service and I know how to parse and use VCAP_SERVICE variable too.

My requirement is : I want to develop user-provided-service.

UserProvided Service:User-provided Service Instances are a mechanism to deliver credentials to applications for service instances which have been pre-provisioned outside of Cloud Foundry.

I have created a Cloud Foundry service using ServiceBrocker API. In this case user can not pass any credentials/arguments to service.

eg:
When we run command:

cf create-service <ServiceName>

Following arguments gets passed by default : - "service_id", "plan_id", "organization_guid" and "space_guid".

However if we want to pass some more details like," Credentials for some endpoint" which service needs; we can not.For that I think we need to create User Provided Service.
I want to know the architecture of user provided service so that I can develop.


Thanks,
Chetana R

Ken Krueger

unread,
Jan 19, 2015, 8:26:54 AM1/19/15
to vcap...@cloudfoundry.org
Chetana,

I think you may have misunderstood the difference between a custom service and a user provided service.  This is a common point of confusion when starting out so let me see if I can help you.

A custom service is a service is one which you create a service broker for, install into CF, and appears as a marketplace service.  Your broker must implement the create, delete, bind, and unbind functions for the service.  For example if you wanted to create a custom service that created database instances, you code in the broker would need to know how to create and delete databases (provisioning / unprovisioning).  

A user provided service (http://docs.cloudfoundry.org/devguide/services/user-provided.html) is completely different.  It is created via the create-user-provided-service command.  It does NOT have any service broker.  It does not provision / unprovision any resources. It is more like a set of glorified environment variables.  When you create a user provided service, you decide what properties it will contain and what their values will be.  Whatever you define using the create-user-provided-servicer (or cups) command will appear in the VCAP_SERVICES variable automatically once the ups is bound to your application.  You can also create a ups via the manifest.

Based on your description above, I'm not sure if you are trying to create a user provided service or a custom service.  The key difference is whether you expect CF to to provision / unprovision resources or not.  If so, you want a custom service, if not, user provided service.  If you can describe your use case a bit it will be easy to determine which one you really want.

thx,
k

--
You received this message because you are subscribed to the Google Groups "Cloud Foundry Developers" group.
To view this discussion on the web visit https://groups.google.com/a/cloudfoundry.org/d/msgid/vcap-dev/b4312f1e-0a36-4088-a68b-78c378e7a686%40cloudfoundry.org.

To unsubscribe from this group and stop receiving emails from it, send an email to vcap-dev+u...@cloudfoundry.org.



--
Ken Krueger  
Manager, Global Education Delivery
407 256 9737 Mobile
kenkrueger65 Skype

Education questions?  educ...@pivotal.io

Daniel Watrous

unread,
Jan 19, 2015, 9:05:41 AM1/19/15
to vcap...@cloudfoundry.org
I would start here, to understand how services work:

Next, follow this to make sure you know how managed services work:

Finally, you can use this to make user-provided services work:

I created these two repositories to support those articles which implement the latest versions of the service broker API and a plausible service:

Daniel

Chetana Rachappanavar

unread,
Jan 19, 2015, 10:05:08 AM1/19/15
to vcap...@cloudfoundry.org
Hi Ken,

Thank you very much for detailed explanation.

I want to create user-provided-service which need not have provision/deprovision.When we create service instance using CUPS command I want to accept credentials of some web application.These creds will be maid available to a application which binds to it.

For command like: cf cups/create-service <Service_instance> -p {credentials}.

I want a service like  <Service_Instanc> , which will be available in market place.I want write this service in Java .This will accept credentials and set credentials in VCAP_SERVICES environment variable when application bind to it.

I am not getting what should be its package structure/mandatory implementation so that it is acceptable by CF as user-provided-service.

Please provide some inputs/documentation for this.


Thanks,
Chetana R

James Bayer

unread,
Jan 19, 2015, 11:10:39 AM1/19/15
to vcap...@cloudfoundry.org
Chetana there are 2 things to understand.

first is the Provider of the service. with user-provided-services, cloud foundry requires zero knowledge of the implementation of the service. there is no package structure or mandatory implementation. the provider of this service could be a person behind a closed door for someone to whisper a passphrase, it does not have to be software.

second is the Client of the Service. with user provided services, whoever creates must know the connection information of the provider, perhaps the location of the door and the passphrase to get past the door. when creating the service, you have the opportunity to provide whatever name value pairs you want. those name value pairs will be given to any app bound to the service in the apps VCAP_SERVICES environment variable.



To unsubscribe from this group and stop receiving emails from it, send an email to vcap-dev+u...@cloudfoundry.org.



--
Thank you,

James Bayer

Shannon Coen

unread,
Jan 19, 2015, 11:07:17 PM1/19/15
to vcap...@cloudfoundry.org
Hello Chetana,

Could you please explain what you are trying to do? Forget about implementation and Cloud Foundry terms. Then we can recommend how Cloud Foundry can help.

Some additional comments inline...

On Sunday, January 18, 2015 at 11:48:54 PM UTC-8, Chetana Rachappanavar wrote:

I want to create user provided service. 

The documentation Dieu provided explains how to create a user-provided service instance. Is this not what you want? There's really no such thing in Cloud Foundry as a "user provided service". User-provided service instances are associated with a fake service called "user-provided" which exists only as a hard-coded string in Cloud Controller. It's not a Managed Service; user-provided service instances are not created by a service broker.

I recommend reading this documentation, as it explains the difference between Managed and User-provided service instances: http://docs.cloudfoundry.org/devguide/services/.
 

Could you please guide me the documentation or sample project or project with which I can start developing service.

If you are interested in developing a service for Cloud Foundry, that is something very different; we do not call these "user-provided". Services that are integrated with Cloud Foundry via the Service Broker API enable developers to create service instances automatically through the Services Marketplace. We call these services Managed Services.

Here is the documentation for developing Managed Services:  http://docs.cloudfoundry.org/services/


On Monday, January 19, 2015 at 12:11:18 AM UTC-8, Chetana Rachappanavar wrote:
Thanks for the reply. I want to develop user provided service. The link you gave tells about how to create service instance of user provided service.

When you say "develop user provided service" I am confused because there is nothing to develop. As I mentioned above, user-provided service instances are not created by a service broker. User-provided service instances are fake service instances that are manually created and bound to applications to deliver credentials for a pre-existing resource (provisioning has nothing to do with Cloud Foundry) to the VCAP_SERVICES environment variable.

Here's a typical use case for user-provided service instances

Your IT team manages an Oracle database. The Oracle server is not integrated with Cloud Foundry, there is no service broker, and developers have no ability to create or manage databases themselves. Still, your developers want to use an Oracle database with applications pushed to Cloud Foundry. So a DBA or IT team creates credentials for a database and delivers them to the developer directly (email, written on paper, over the phone, etc). 

So how does the developer configure their application to use these credentials? Cloud Foundry applications typically use environment variables for configuration. A developer can create an environment variable like this:

$ cf set-env myapp database mysql://user:pass@hostname:port/dbname
Setting env variable 'database' to 'mysql://user:pass@hostname:port/dbname' for app myapp in org scoen / space test2 as admin...
OK

A developer can see what environment variables have been configured for their application like this:

$ cf env myapp
Getting env variables for app myapp in org scoen / space test2 as admin...
OK

System-Provided:
{
 "VCAP_APPLICATION": {
  "application_name": "myapp",
  "application_uris": [
  ],
  "application_version": "6d24b42a-3d2d-4a4b-863f-033424fae737",
  "limits": {
   "disk": 1024,
   "fds": 16384,
   "mem": 1024
  },
  "name": "myapp",
  "space_id": "e3696fcb-7a8f-437f-8692-436558e45c7b",
  "space_name": "test2",
  "uris": [
  ],
  "users": null,
  "version": "6d24b42a-3d2d-4a4b-863f-033424fae737"
 }
}

User-Provided:
database: mysql://user:pass@hostname:port/dbname

However, there's a better way. 

When binding a service instance to an application, Cloud Foundry puts credentials for the service instance into the environment VCAP_SERVICES. Credentials for all service instances bound to an app are put in this environment variable. So Cloud Foundry applications typically know how to parse VCAP_SERVICES for service credentials. Instead of changing application code to use a different environment variable, wouldn't it be great if developers could add the credentials given to them by the Oracle DBA to VCAP_SERVICES? 

This is what user-provided service instances are for. 

A developer creates a user-provided service instance manually, using the credentials given to them by the DBA. This creates a fake service instance in their space.

$ cf cups myupsi -p '{"uri":"mysql://user:pass@hostname:port/dbname"}'
Creating user provided service myupsi in org scoen / space test2 as admin...
OK

Binding the user-provided service instance to an application inserts the credentials into VCAP_SERVICES.

$ cf env myapp
Getting env variables for app myapp in org scoen / space test2 as admin...
OK

System-Provided:
{
 "VCAP_SERVICES": {
  "user-provided": [
   {
    "credentials": {
     "uri": "mysql://user:pass@hostname:port/dbname"
    },
    "label": "user-provided",
    "name": "myupsi",
    "syslog_drain_url": "",
    "tags": []
   }
  ]
 }
}

 
I want a documentation which explains, how we can accept the user provided credentials in code and puts in VCAP_Variables.

I'm sorry, I don't know what you mean by "how we can accept the user provided credentials in code". 

Do you mean, how can you create user-provided service instances automatically? Here is the Cloud Foundry API documentation: 

However, if you are considering generating user-provided service instances automatically, then you should probably consider using a service broker to enable developers to create instances of a Managed Service through the Marketplace: http://docs.cloudfoundry.org/services/

It sounds like you have created a service broker already. Please explain what you are trying to achieve, and we can recommend how to accomplish it.
 
Thank you,
Shannon


Shannon Coen

unread,
Jan 19, 2015, 11:48:53 PM1/19/15
to vcap...@cloudfoundry.org
Inline...


On Monday, January 19, 2015 at 2:09:50 AM UTC-8, Chetana Rachappanavar wrote:
Yeah, I know that we get VCAP_SERVICES when we bind the service and I know how to parse and use VCAP_SERVICE variable too.

My requirement is : I want to develop user-provided-service.

UserProvided Service:User-provided Service Instances are a mechanism to deliver credentials to applications for service instances which have been pre-provisioned outside of Cloud Foundry.

I have created a Cloud Foundry service using ServiceBrocker API. In this case user can not pass any credentials/arguments to service.

eg:
When we run command:

cf create-service <ServiceName>

Following arguments gets passed by default : - "service_id", "plan_id", "organization_guid" and "space_guid".

However if we want to pass some more details like," Credentials for some endpoint" which service needs; we can not.

It sounds like you want to enable users to provide configuration options when creating instances of a service offered by your service broker. Is this correct?Unfortunately, Cloud Foundry does not this. However, it is on our roadmap. In the meantime, you can enable users to configure instances directly through a dashboard offered by your service.

Could you please explain why your service requires "credentials for some endpoint"? As my team is responsible for implementing this feature, it is helpful for me to hear any details of your use case you can share.
 
For that I think we need to create User Provided Service.
I want to know the architecture of user provided service so that I can develop.


You may be assuming that because the user-provided service instance feature supports adding credentials, that User Provided Service must be a type of service broker. This is incorrect. There is no broker for user-provided service instances. User-provided service instances are a built-in feature of Cloud Foundry.


Best,
Shannon 

 

Shannon Coen

unread,
Jan 20, 2015, 12:04:02 AM1/20/15
to vcap...@cloudfoundry.org
Inline...


On Monday, January 19, 2015 at 7:05:08 AM UTC-8, Chetana Rachappanavar wrote:
I want to create user-provided-service which need not have provision/deprovision.When we create service instance using CUPS command I want to accept credentials of some web application.These creds will be maid available to a application which binds to it.

When a user creates a user-provided service instance, credentials are stored in Cloud Foundry. When applications are bound to the user-provided service instance, these credentials are added to VCAP_SERVICES for those applications.

It sounds like you want to build a service that takes credentials as user input with the create request, then gives these same credentials to applications when they are bound the service instance. Why does your service broker need the credentials? Does your broker register accounts with credentials provided by a user? If this is the case, I would suggest either:

1. If the user must provide information to create an account, have the user register with the service directly outside of Cloud Foundry. Then, in order to deliver credentials they registered with to applications, users can create a user-provided service instance and bind it to applications. This solution does not require a service broker; it uses the built-in user-provided service instances feature.

OR

2. Have the service generate credentials randomly when the user creates and instance (figure out how to avoid the requirement for user input). This way you can use a service broker to create a service instance, and on binding with an app, deliver the randomly generated credentials. This solution requires a service broker. 
 

For command like: cf cups/create-service <Service_instance> -p {credentials}.

I want a service like  <Service_Instanc> , which will be available in market place.I want write this service in Java .This will accept credentials and set credentials in VCAP_SERVICES environment variable when application bind to it.

This is not supported by Cloud Foundry yet.

Mike Heath

unread,
Jan 26, 2015, 3:25:29 PM1/26/15
to vcap...@cloudfoundry.org
Chetana, it sounds like you want support for user provided arguments at service instance provision/bind time. We've been asking for this feature for a long time. It would be really nice if the "user provided service" were a service broker like any other and the server broker API supported user provided data. I think this would allow you to do what you're trying to do. Unfortunately, this is not how user provided services work.

-Mike

Chetana Rachappanavar

unread,
Jan 29, 2015, 6:57:47 AM1/29/15
to vcap...@cloudfoundry.org
Thank you every one for the reply. Your replies were great help in understanding user provided services.

Chetana R
Reply all
Reply to author
Forward
0 new messages