Cloud Foundry service broker开发部署实例解析(下)

云计算
通过上篇,我们得到service broker的程序包,之后我们将其部署到CF上,得到真正能使用的市场服务。

通过上篇,我们得到service broker的程序包,之后我们将其部署到CF上,得到真正能使用的市场服务。

[[130785]]

发布应用程序

将源代码中的application.properties里的spring.jpa.hibernate.ddl-auto配置为create,编译打包发布到CF上:

  1. cf push samplebroker -p ./cf-sample-servicebroker.jar1 

创建一个MySQL服务实例,并绑定到此应用上:

  1. cf cs p-mysql 100m-dev samplebrokerdb 
  2.  
  3. cf bs samplebroker samplebrokerdb 
  4.  
  5. cf restart samplebroker123 

将源代码中的application.properties里的spring.jpa.hibernate.ddl-auto配置为validate,重新编译打包发布到CF上:

  1. cf push samplebroker -p ./cf-sample-servicebroker.jar1 

初始化服务信息

用ssh登陆Ops Manager的ubuntu,获取服务ID,其中的adminpassword就是Ops Manager的Elastic Runtime的credential页里的UAA模块admin的密码,samplebroker.open.mydomain.com是上一步发布的应用的域名

  1. curl -i -H "Content-type: application/json" -b cookies.txt -X GET http://admin:adminpassword@samplebroker.open.mydomain.com/v2/catalog1 

为对应的服务ID添加3个服务计划,其中的GUID是上一步中获取的,具体计划的详细信息请根据实际的资源情况进行修改

  1. curl -i -H "Content-type: application/json" -b cookies.txt -X POST http://admin:adminpassword@samplebroker.open.mydomain.com/v2/catalog/services/590017dc-1fd2-4cbc-99e6-ae668107cc7a/plans -d '{"name" : "bronze","description" : "all apps share 1 RV node","metadata" : {"max_size" : "10240M","connections" : 100,"bullets" : ["Each app has its own credential","100 apps at most"],"displayName":"Bronze"}}' 
  2.  
  3. curl -i -H "Content-type: application/json" -b cookies.txt -X POST http://admin:adminpassword@samplebroker.open.mydomain.com/v2/catalog/services/590017dc-1fd2-4cbc-99e6-ae668107cc7a/plans -d '{"name" : "silver","description" : "10 apps share 1 RV node","metadata" : {"max_size" : "20480M","connections" : 10,"bullets" : ["Each app has its own credential","10 apps for 1 RV node at most"],"displayName":"Silver"}}' 
  4.  
  5. curl -i -H "Content-type: application/json" -b cookies.txt -X POST http://admin:adminpassword@samplebroker.open.mydomain.com/v2/catalog/services/590017dc-1fd2-4cbc-99e6-ae668107cc7a/plans -d '{"name" : "gold","description" : "Each apps has its own RV node","metadata" : {"max_size" : "30720M","connections" : 1,"bullets" : ["Each app has its own credential","1 app for 1 RV node at most"],"displayName":"Gold"}}'123 

根据前三条命令的输出里的ID信息为每个服务计划添加单价

  1. curl -i -H "Content-type: application/json" -b cookies.txt -X PUT http://admin:adminpassword@samplebroker.open.mydomain.com/v2/catalog/services/590017dc-1fd2-4cbc-99e6-ae668107cc7a/plans/29cf4cb9-4d85-42a2-89b8-65db630357c5/costs -d '{"amount":{"usd":1.0},"unit":"day"}' 
  2.  
  3. curl -i -H "Content-type: application/json" -b cookies.txt -X PUT http://admin:adminpassword@samplebroker.open.mydomain.com/v2/catalog/services/590017dc-1fd2-4cbc-99e6-ae668107cc7a/plans/12dd3ed1-7076-409e-8a64-568c3edd82e4/costs -d '{"amount":{"usd":10.0},"unit":"day"}' 
  4.  
  5. curl -i -H "Content-type: application/json" -b cookies.txt -X PUT http://admin:adminpassword@samplebroker.open.mydomain.com/v2/catalog/services/590017dc-1fd2-4cbc-99e6-ae668107cc7a/plans/b4897b00-b6cc-4295-9dbb-bf4084fe4c97/costs -d '{"amount":{"usd":100.0},"unit":"day"}'123 

对于每一个服务计划,添加资源池,其中的资源信息按照实际情况进行修改

  1. curl -i -H "Content-type: application/json" -b cookies.txt -X PUT http://admin:adminpassword@samplebroker.open.mydomain.com/v2/catalog/services/590017dc-1fd2-4cbc-99e6-ae668107cc7a/plans/29cf4cb9-4d85-42a2-89b8-65db630357c5/pool -d '{"kcxpaddr":"10.23.119.61","kcxpport":"21000","rvipaddr":"10.23.119.57","rvport":"7500","username":"sxiang","password":"888888"}' 
  2.  
  3. curl -i -H "Content-type: application/json" -b cookies.txt -X PUT http://admin:adminpassword@samplebroker.open.mydomain.com/v2/catalog/services/590017dc-1fd2-4cbc-99e6-ae668107cc7a/plans/12dd3ed1-7076-409e-8a64-568c3edd82e4/pool -d '{"kcxpaddr":"10.23.119.61","kcxpport":"21000","rvipaddr":"10.23.119.57","rvport":"7500","username":"sxiang","password":"888888"}' 
  4.  
  5. curl -i -H "Content-type: application/json" -b cookies.txt -X PUT http://admin:adminpassword@samplebroker.open.mydomain.com/v2/catalog/services/590017dc-1fd2-4cbc-99e6-ae668107cc7a/plans/b4897b00-b6cc-4295-9dbb-bf4084fe4c97/pool -d '{"kcxpaddr":"10.23.119.61","kcxpport":"21000","rvipaddr":"10.23.119.57","rvport":"7500","username":"sxiang","password":"888888"}'123 

发布service

  1. cf create-service-broker p-sample admin adminpassword https://samplebroker.open.mydomain.com1 

创建service broker

获取3个服务计划的GUID

  1. cf curl /v2/service_plans1 

将3个服务计划设置为可见

  1. cf curl /v2/service_plans/54beb2e7-a5c5-40c4-9a9b-e12c8edef4be -X PUT -d '{"public":true}'1 

扩容

扩容时,需要使用a步增加资源池的容量,然后修改MySQL中的数据,再重启service broker应用

到此为止,在CLI或者GUI的maketplace里,就能找到这个p-sample的服务了。声明,本文中的源代码来源于github的开源代码,笔者进行了修正和完善。
 

责任编辑:Ophira 来源: 云计算实务博客
相关推荐

2015-03-30 14:57:03

paascloudfoundrservice bro

2011-05-06 15:48:35

Service BroSQL Server

2017-07-17 15:50:17

微服务Docker架构

2011-04-22 10:13:42

Cloud FoundAzure

2015-04-14 11:10:22

PaaSCloudFoundrBuildpack

2018-08-22 18:16:47

2015-06-09 10:36:13

Cloud FoundAzurePaaS

2013-04-26 17:38:52

大数据全球技术峰会

2012-07-19 09:13:40

VMware云计算Cloud Found

2011-05-06 15:37:10

Service BroSQL Server

2009-12-01 10:49:44

Visual Stud

2013-10-23 10:21:57

OpenStack

2012-05-14 10:49:25

Cloud Found

2012-12-07 10:00:25

SpringOneCloud FoundVMware

2011-11-15 16:48:58

Zend Studio

2011-05-06 15:00:52

Service BroSQL Server

2022-07-03 06:58:46

deno开发nodejs

2014-03-07 09:26:46

PaaSCloud Found

2015-12-16 11:11:52

Cloud FoundSpring云计算

2012-03-27 11:40:55

vmwareCloud Found
点赞
收藏

51CTO技术栈公众号