Giter VIP home page Giter VIP logo

cloudfoundry-service-broker's Introduction

cloudfoundry-service-broker is no longer actively maintained by VMware, Inc.

Sample Spring Boot project using the Spring Cloud - Cloud Foundry Service Broker 1.x.

Note: This sample will not be updated to be compatible with Spring Cloud Open Service Broker 2.x. A separate Spring Cloud Open Service Broker 2.x sample project is available.

Overview

This sample project uses the Spring Cloud - Cloud Foundry Service Broker to implement a MongoDB service. The MongoDB service also uses spring-boot-data-mongodb to persist service instances and bindings.

Getting Started

You need to install and run MongoDB somewhere and configure connectivity in application.yml.

Build it:

./gradlew build

After building, you can push the broker app to Cloud Foundry or deploy it some other way and then register it to Cloud Foundry.

Enable Auth in your MongoDB instance

Add the Initial Admin User:

$ mongo
> use admin
> db.createUser({ user: 'admin', pwd: 'password', roles: [{"role" : "readWriteAnyDatabase","db" : "admin"},{"role" : "userAdminAnyDatabase","db" : "admin"}] });

Update your mongod.conf file to enable authorization. For example, add lines like these:

security:
  authorization: enabled

Restart your Mongo service and test that authentication is working as expected:

mongo --authenticationDatabase "admin" -u "admin" -p "password"

Refer to the MongoDB docs for more details: https://docs.mongodb.com/manual/tutorial/enable-authentication/

Deploy the Service Broker to Cloud Foundry

The service broker is configured via environment variables, which are defined in the manifest.yml file. Make the necessary changes to the MongoDB config in order to connect to your Mongo instance.

Push the service broker as an app to Cloud Foundry: cf push

Register the service broker using the default username and the password obtained from the previous step: cf csb mongodb admin admin https://mongodb-service-broker.local.pcfdev.io

Enable access to the service broker: cf enable-service-access mongodb

Create a service instance: cf cs mongodb default mymongodb

cloudfoundry-service-broker's People

Contributors

asaikali avatar daniellavoie avatar marcingrzejszczak avatar michaelbannister avatar michaelsteven avatar scottfrederick avatar spgreenberg avatar spring-operator avatar trevormarshall avatar vtrbtf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cloudfoundry-service-broker's Issues

Connecting to mongod instance

Hi,

My question isn't strictly in the scope of this project – perhaps I should post to the cloud-foundry lists – but if you can answer this easily (and even update your README) I'd be very grateful!

You need to install MongoDB somewhere and configure connectivity in MongoConfig.java
If I'm running my own CF instance using bosh-lite, and MongoDB running on my host machine, what configuration do I need to mess with so that the service broker can "see" my host machine? I've tried using my router's 192.168.x.x address but I get a failure when trying to create a service instance:

$ cf create-service "Mongo DB" "Default Mongo Plan" mongo-instance-1
Creating service mongo-instance-1 in org me / space development as admin...
FAILED
Server error, status code: 502, error code: 10001, message: Service broker error: Read operation to server /192.168.0.4:27017 failed on database test; nested exception is com.mongodb.MongoException$Network: Read operation to server /192.168.0.4:27017 failed on database test

Thanks

P.S. I might be able to submit a pull request updating this to work with service broker API 2.4 & version 2.4.0 of your spring-boot-cf-service-broker, if you don't already have that in progress. (Also latest version of MongoDB.) I'm not sure I've understood some of the API changes though so it may need some tweaking…

create-service-broker error

Hi,

I've build and pushed the app to cloud foundry.But when I try

cf create-service-broker mongobroker admin admin <>

I'm getting a

Creating service broker mongobroker as admin...
FAILED
Server error, status code: 502, error code: 10001, message: The service broker r
ejected the request to https://mongodb-service-broker.in-XXX.XXX.com/
/v2/catalog. Status Code: 404 Not Found, Body: {"timestamp":1487310707790,"statu
s":404,"error":"Not Found","message":"No message available","path":"/catalog"}

Am I missing something here ?

Thanks
Sravya

Master does not compile and produces warnings

 ./gradlew build
The plugin id 'spring-boot' is deprecated. Please use 'org.springframework.boot' instead.
:compileJava
warning: [options] bootstrap class path not set in conjunction with -source 1.7
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
1 warning
:processResources
:classes
:findMainClass
:jar
:bootRepackage
:assemble
:compileTestJava
warning: [options] bootstrap class path not set in conjunction with -source 1.7
/Users/asaikali/git/demos/cloudfoundry-service-broker/src/test/java/org/springframework/cloud/servicebroker/mongodb/service/MongoServiceInstanceServiceTest.java:155: error: no suitable constructor found for CreateServiceInstanceRequest(String,String,String,String)
		return new CreateServiceInstanceRequest(SVC_DEF_ID, SVC_PLAN_ID, "organizationGuid", "spaceGuid")
		       ^
    constructor CreateServiceInstanceRequest.CreateServiceInstanceRequest() is not applicable
      (actual and formal argument lists differ in length)
    constructor CreateServiceInstanceRequest.CreateServiceInstanceRequest(String,String,String,String,Context,Map<String,Object>) is not applicable
      (actual and formal argument lists differ in length)
    constructor CreateServiceInstanceRequest.CreateServiceInstanceRequest(String,String,String,String,Map<String,Object>) is not applicable
      (actual and formal argument lists differ in length)
1 error
1 warning
:compileTestJava FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileTestJava'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 4.905 secs

Use externalized configuration to define service broker catalog

For catalog management, spring-boot-cf-service-broker provides a default implementation that requires the broker to just provide an implementation of a Catalog bean.
An improvement would be to enable the use of externalized configuration (properties files, YAML files, environment variables or command-line arguments) to set Catalog bean attributes.

Then, a very basic catalog definition using env variables would be :

$ export SERVICES_DEFINITIONS[MONGO_DB]_ID=mongodb-service-broker 
$ export SERVICES_DEFINITIONS[MONGO_DB]_NAME=Mongo DB
$ export SERVICES_DEFINITIONS[MONGO_DB]_DESCRIPTION=A simple MongoDB service broker implementation
$ export SERVICES_DEFINITIONS[MONGO_DB]_PLANS[DEFAULT]_ID=mongo-plan
$ export SERVICES_DEFINITIONS[MONGO_DB]_PLANS[DEFAULT]_NAME=Default Mongo Plan
$ export SERVICES_DEFINITIONS[MONGO_DB]_PLANS[DEFAULT]_DESCRIPTION=This is a default mongo plan. All services are created equally

This feature can be extended by enabling a remote externalized configuration

Error when provision service with cf cs

I've been working on this error for a while, with no result. Any idea what I missed?
Thanks
Beth Tran

Here's my set up

  1. One VM running mongodb (192.168.250.40), exposing port 27017
    I can access Guest VM mongodb with my mongodb credentials (admin/admpass)

  2. Another VM (192.168.59.4) running CloudFoundry
    application.yml has mongodb credential set as admin/admpass)
    This application is deployed as service broker

  3. cf marketplace
    service plans description
    Mongo DB Default Mongo Plan* A simple MongoDB service broker implementation

  4. cf cs "Mongo DB" "Default Mongo Plan" bethMongodbserviceInstance

  5. Log for mongodb did not log anything for the connection from step #4

  6. "cf cs" generate this error - as Connection refused
    Server error, status code: 502, error code: 10001, message: Service broker error: Timed out after 10000 ms while waiting to connect. Client view of cluster state is {type=Unknown, servers=[{address=192.168.250.40:27017, type=Unknown, state=Connecting, exception={com.mongodb.MongoException$Network: Exception opening the socket}, caused by {java.net.ConnectException: Connection refused}}]; nested exception is com.mongodb.MongoTimeoutException: Timed out after 10000 ms while waiting to connect. Client view of cluster state is {type=Unknown, servers=[{address=192.168.250.40:27017, type=Unknown, state=Connecting, exception={com.mongodb.MongoException$Network: Exception opening the socket}, caused by {java.net.ConnectException: Connection refused}}]

"cf cs" ERRORS

I have mongodb running at localhost:27017 and able to connect to it using robomongo.
Also, I deploy cloudfoundry-service-broker to CF and register this app as a mongo service broker.

"cf apps" returns

  • mongodb-cf-service-broker started 1/1 1G 1G mongodb-cf-service-broker.myhost.com

After register with CF, "cf marketplace" returns

  • Mongo DB Default Mongo Plan* A simple MongoDB service broker implementation

However, "cf cs "Mongo DB" "Default Mongo Plan" testMongodbInstance" returns follow ERROR

I've tried to look at this error for a while; but could not find out why. Command using curl to query for the broker's catalog is successful and return the catalog.
Any tips?
Thanks
Beth
--------ERROR--------
Server error, status code: 502, error code: 10001, message: Service broker error: Timed out after 10000 ms while waiting to connect. Client view of cluster state is {type=Unknown, servers=[{address=localhost:27017, type=Unknown, state=Connecting, exception={com.mongodb.MongoException$Network: Exception opening the socket}, caused by {java.net.ConnectException: Connection refused}}]; nested exception is com.mongodb.MongoTimeoutException: Timed out after 10000 ms while waiting to connect. Client view of cluster state is {type=Unknown, servers=[{address=localhost:27017, type=Unknown, state=Connecting, exception={com.mongodb.MongoException$Network: Exception opening the socket}, caused by {java.net.ConnectException: Connection refused}}]

pom.xml files out of sync with build.gradle depndency versions

The pom.xml file version in based on spring boot 1.3 but the gradle version is based on boot 1.5.9. It might be easier to delete the pom.xml file and only keep the gradle build to make sure that the sample always work.

Also the maven wrapper is missing from the project even though it has a mvnw which seems to indicate that the wrapper is present.

Unable to create-service using instructions provided in README.md

Hi

At the last step of creating the MongoDB service, I am getting the following error.
Environment: Macbook running BOSH v2 and CF CLI with BOSH and CF setup on VirtualBox. MongoDB running as standalone on Macbook on NAT network.

It seems that CF is not able to reach the mongodb server running on my macbook. I provided the correct MongoDB auth details and the ip address in the Manifest file.

~/workspace/cloudfoundry-service-broker> cf cs mongodb default mymongodb
Creating service instance mymongodb in org atg / space test-space as admin...
FAILED
Server error, status code: 502, error code: 10001, message: Service broker error: Timed out after 30000 ms while waiting for a server that matches ReadPreferenceServerSelector{readPreference=primary}. Client view of cluster state is {type=UNKNOWN, servers=[{address=192.168.50.1:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused (Connection refused)}}]; nested exception is com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that matches ReadPreferenceServerSelector{readPreference=primary}. Client view of cluster state is {type=UNKNOWN, servers=[{address=192.168.50.1:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused (Connection refused)}}]

Your help will be really appreciated.

Thanks.

Username & Password

Hi,

I pushed this broker to my private CF as an app. while I'm trying to connect it asks for user name and password.

The message: "The server XXX requires username and password. The servers says:Spring".

There is any user & pwd in order to use it?

Problem with connecting host

Hi,
I am trying to push mongo db service broker app to PCF. Under MongoConfig.java, I changed localhost to my host (domain is registered in our PCF account) and changed in application.yml file. When I trying to push an application it throws me exception.

2016-07-23T21:30:08.88+0530 [APP/0] ERR java.lang.reflect.InvocationTargetException
2016-07-23T21:30:08.88+0530 [APP/0] ERR at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2016-07-23T21:30:08.88+0530 [APP/0] ERR at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
2016-07-23T21:30:08.88+0530 [APP/0] ERR at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
2016-07-23T21:30:08.88+0530 [APP/0] ERR at java.lang.reflect.Method.invoke(Method.java:497)
2016-07-23T21:30:08.88+0530 [APP/0] ERR at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:53)
2016-07-23T21:30:08.88+0530 [APP/0] ERR at java.lang.Thread.run(Thread.java:745)
2016-07-23T21:30:08.89+0530 [APP/0] ERR Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'mongoServiceInstanceBindingServic
e' defined in file [/home/vcap/app/org/springframework/cloud/servicebroker/mongodb/service/MongoServiceInstanceBindingService.class]: Unsatisfied dependency expressed through constructor
argument with index 0 of type [org.springframework.cloud.servicebroker.mongodb.service.MongoAdminService]: : Error creating bean with name 'mongoAdminService' defined in file [/home/vca
p/app/org/springframework/cloud/servicebroker/mongodb/service/MongoAdminService.class]: Unsatisfied dependency expressed through constructor argument with index 0 of type [com.mongodb.Mo
ngoClient]: : Error creating bean with name 'mongoClient' defined in class path resource [org/springframework/cloud/servicebroker/mongodb/config/MongoConfig.class]: Bean instantiation vi
a factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.mongodb.MongoClient]: Factory method 'mongoClient' threw exc
eption; nested exception is com.mongodb.MongoException: host and port should be specified in host:port format; nested exception is org.springframework.beans.factory.BeanCreationException

I got above exception. Again, I tried with localhost to push the app and it is running. But I can't create service instance under localhost.

Thanks in advance.

No license and file headers.

I want to use your BrokerConfig.java, but the project has no license. Could you add one? I think that MIT would be the best. Also, it would be great if BrokerConfig.java would have a copyright header.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.