Marketplace & Service Instances

We never run production code against H2 Database, We need some NoSql/RDBMS Solutions like Cassndra/MongoDB/Oracle/Mysql/Postgres etc...

The Problem Statement

How do I provision a service to my space.

Steps

  1. On the terminal , type in cf m
  2. You will get the listing of all the services that you would be able to create.
  3. I'm interested in a postgres instance

    postgres                   shared, shared-nr   Reliable PostgrSQL Service
    
  4. To get more details about a service type in cf marketplace -s <SERVICE_NAME>, For example cf marketplace -s postgres

     Getting service plan information for service postgres as *******@**.com...
     OK
    
     service plan   description                                                     free or paid   
     shared         A Reliable PostgreSQL database on a shared server.              free   
     shared-nr      A PostgreSQL database with no replication on a shared server.   free
    
  5. So how do I go about creating an Postgres instance

         cf cs postgres shared-nr database
    
  6. Time to bind the Postgres instance to our todo-service service.
    • There are 2 ways this can be done
      • Using cf-cli : cf bs <APP_NAME> <SERVICE_INSTANCE_NAME>, For eg: cf bs todo-service database
      • Using manifest.yml services block
    • I prefer the second method. Checkout this commit for details
  7. Create some entity and RestResource, Check this commit for details
  8. So as to follow the 12factor Admin process, I'm using flyway to make migrations easier, Check this commit for details
  9. Time for mvn clean install && cf push

Tips

  • For help on any command in cf-cli, type in cf help <COMMAND>, for eg: cf help cs , cf help m
  • If a service is bound to an application, you need to restage the application using cf restage <APP_NAME> command
  • Flyway is not database agnostic
  • Make sure that you turn off any ddl operation by hibenate by setting spring.jpa.generate-ddl=false
  • Checkout Hibernate Licensing to make sure you don't get into trouble later.

References