User provided service in cloud foundry

2019-07-12 01:53发布

I read cloud foundry docs about user provided service but not sure that I got it and how really to use it.

> 1. my question is what is the use case for it?

(I understand that the service is not available in the market place...)

> 2.when it recommended to use it and when not ?
>  
> 3. There is some real world example for it which I can use to create, I mean some  E2E guide ?

2条回答
对你真心纯属浪费
2楼-- · 2019-07-12 02:14

Create user provided serice in Pivotal Cloud Foundry using CLI

cf cups oracle-db -p "url, username, password"
url> jdbc:oracle:thin:@database_host_name:port/sid    
username> admin
password> admin
Creating user provided service oracle-db in org
OK

Access the service in spring boot application

 datasource:
    url: ${vcap.services.oracle-db.credentials.url}
    username: ${vcap.services.oracle-db.credentials.username}
    password: ${vcap.services.oracle-db.credentials.password}

Also put the service name in Manifest file

services: 
   - oracle-db

If you need complete demo spring boot application below is link https://github.com/rathore-girdharsingh/pcf-oracle-user-provided-service

查看更多
3楼-- · 2019-07-12 02:39
  1. my question is what is the use case for it?

It's basically a catch-all. It's meant to handle anything that's not covered by a service broker in your environment. Plus it gives you the additional flexibility for passing info to your apps.

2.when it recommended to use it and when not ?

If you have a service broker available use it. Service brokers are easier for CF developers to use, and they can also provide additional metadata like labels and tags that you cannot set with a user provided service. This additional metadata makes it easier for applications to detect and handle the services.

Ex: If your application is looking for a bound MySQL service (i.e. searching through all bound services for a particular type of service), you would typically look at the label & tags to find it in a generic way. If you bind a user provided service, you don't get this information so you have to look at the service data (i.e. is there a URL, what does it look like, etc.) or pattern match the name to make the distinction.

  1. There is some real world example for it which I can use to create, I mean some E2E guide ?

The simplest and most common case for using a user provided service is to bind a service for which there is no available service broker. This might be a custom service you created or maybe just something not supported by the CF installation / provider.

Because user provided services are a generic mechanism to bind data to an app you can use it for other things too.

Ex:

  1. Service instances are scoped to an org & space. If you want to share a service from one org & space to a different org & space, you can create a user provided service in the second org & space passing in the credentials from the first org & space.

  2. Turning an application into a service. Perhaps you have a micro service deployed as an app on PCF. If you want another app to use your micro service, you can create a user provided service and pass the URL for your micro service to the consuming app. Sure, you can do this other ways too, but this is a really simple way to implement it on CF.

  3. Passing any data to multiple apps. Let's say you have a key or common setting that you want to pass to 10 apps you have deployed on CF. You could do this by setting the same env variable for all 10 of your apps, or instead you could put the data into a service and bind the service to all 10 of your apps. This makes changing the data easier (update one service vs 10 apps) and it scales better (think of updating env variables for 100 apps).

I'm sure there are other use cases too. The point is that they are a flexible part of CF that you can use to share data across your apps.

查看更多
登录 后发表回答