Saturday, February 17, 2018

Managing service instances in PCF


We will look at how to we use the services available in the market place. 

Some basic commands: 
cf marketplace : list all services in the marketplace
cf services: list all service instances created. 

Creating and binding a service from marketplace. 
View list of all the services in the market place

/ $cf marketplace
Getting services from marketplace in org pcfdev-org / space pcfdev-space as user...
OK

service        plans             description
local-volume   free-local-disk   Local service docs: https://github.com/cloudfoundry-incubator/local-volume-release/
p-mysql        512mb, 1gb        MySQL databases on demand
p-rabbitmq     standard          RabbitMQ is a robust and scalable high-performance multi-protocol messaging broker.
p-redis        shared-vm         Redis service to provide a key-value store

Create a new service instance
/ $cf create-service p-mysql 512mb user-db
Creating service instance user-db in org pcfdev-org / space pcfdev-space as user...


/ $cf apps
Getting apps in org pcfdev-org / space pcfdev-space as user...
OK

name          requested state   instances   memory   disk   urls
userservice   started           2/2         512M     512M   userservice-dev.local.pcfdev.io
/ $cf services
Getting services in org pcfdev-org / space pcfdev-space as user...
OK

name      service   plan    bound apps   last operation
user-db   p-mysql   512mb                create succeeded


/ $cf bind-service userservice user-db
Binding service user-db to app userservice in org pcfdev-org / space pcfdev-space as user...
OK

Unbinding and deleting services
/ $cf services
Getting services in org pcfdev-org / space pcfdev-space as user...
OK

name      service   plan    bound apps    last operation
user-db   p-mysql   512mb   userservice   create succeeded

/ $cf unbind-service userservice user-db
Unbinding app userservice from service user-db in org pcfdev-org / space pcfdev-space as user...
OK
/ $cf delete-service user-db

Really delete the service user-db?> y
Deleting service user-db in org pcfdev-org / space pcfdev-space as user...
OK
/ $cf services
Getting services in org pcfdev-org / space pcfdev-space as user...
OK

No services found
/ $

list information about a specific service. 
Cf service user-db

You may not want to bind the service everytime you push an application. You can use the following entries to bind in the app manifest file. 

services:
  • user-db

Some services require to pass some json attributes while binding the services. 
 cf bind-service userservice user-db-c ‘{“ref-name”:”DeiveeService”, role=“Admin”}’

You can also send as a json file. 
Cf bind-service userservice user-db -c /tmp/configuration.json

Other commands 

cf rename-service user-db myuser-db
cf update-service user-db -p 1GB

No comments:

Post a Comment