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
- On the terminal , type in
cf m
- You will get the listing of all the services that you would be able to create.
I'm interested in a postgres instance
postgres shared, shared-nr Reliable PostgrSQL Service
To get more details about a service type in
cf marketplace -s <SERVICE_NAME>
, For examplecf 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
So how do I go about creating an Postgres instance
cf cs postgres shared-nr database
- 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
- Using cf-cli :
- I prefer the second method. Checkout this commit for details
- There are 2 ways this can be done
- Create some entity and RestResource, Check this commit for details
- So as to follow the 12factor Admin process, I'm using flyway to make migrations easier, Check this commit for details
- 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.