Project to understand Cloud Foundry Service Broker
Service Broker for Hashmap as a Service
Repository contains two projects:
1. hashmap-service-broker - Service broker to publish HashMap as a Service
2. hashmap-service-client – Client to consume HashMap as a Service
Technologies used: Java -1.8, Spring Boot - 1.4.2.RELEASE, Spring Cloud, Cloud Foundry Service Broker, Spring Security, JPA, HSQLDB, REST Template, Maven, Junit, Mockito
Deployment Instructions:
-
Build hashmap-service-broker and hashmap-service-client using Maven.
-
Push hashmap-service-broker to PCF using “cf push" command. (manifest.yml file is present in root directory with necessary parameters)
-
Register the service broker using below command:
cf create-service-broker SERVICE_BROKER USERNAME PASSWORD URL [--space-scoped]
Example: cf create-service-broker hashmap-service-broker user password http://hashmap-service-broker-overscented-unthriftiness.cfapps.io --space-scoped
-
Now you should be able to see your service broker in PCF Marketplace. Use below commands to see service details:
cf marketplace [-s SERVICE]
Example: cf marketplace cf marketplace -s HashMap-Service
-
Create service instance using service broker. Use below command:
cf create-service SERVICE PLAN SERVICE_INSTANCE
Example: cf create-service HashMap-Service Basic-HashMap-Service custom-hashmap-service
-
You can view the created services using below command:
cf services
OR
cf service SERVICE_INSTANCE
Example: cf service custom-hashmap-service
-
Push hashmap-service-client to PCF using “cf push" command. (manifest.yml file is present in root directory with necessary parameters)
List o REST APIs to test the services from REST Client (Postman:
-
To view the service catelog
http://USERNAME:PASSWORD@SERVICE_BROKER_ROUTE_URL/v2/catalog
-
To get service binding information from service client
GET -> http://SERVICE_CLIENT_ROUTE_URL/hashmap/info
Example: GET -> http://hashmap-service-client-plummy-assimilator.cfapps.io/hashmap/info
-
To put Key-Value pair in bound hashmap service instance
PUT -> http://SERVICE_CLIENT_ROUTE_URL/hashmap/KEY Request Body - VALUE
Example:
PUT -> http://hashmap-service-client-plummy-assimilator.cfapps.io/hashmap/name Request Body – Rohit Patil
-
To get value for given key from bound hashmap service instance
GET -> http://SERVICE_CLIENT_ROUTE_URL/hashmap/KEY
Example: GET -> http://hashmap-service-client-plummy-assimilator.cfapps.io/hashmap/name
-
To delete value for given key from bound hashmap service instance
DELETE -> http://SERVICE_CLIENT_ROUTE_URL/hashmap/KEY
Example: DELETE -> http://hashmap-service-client-plummy-assimilator.cfapps.io/hashmap/name