Successfully reported this slideshow.
Your SlideShare is downloading. ×

Cloud foundry elastic architecture and deploy based on openstack

Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad

Check these out next

1 of 58 Ad

More Related Content

Slideshows for you (20)

Similar to Cloud foundry elastic architecture and deploy based on openstack (20)

Advertisement

More from OpenCity Community (20)

Recently uploaded (20)

Advertisement

Cloud foundry elastic architecture and deploy based on openstack

  1. 1. CloudFoundry: Elastic Architecture Design and Deploy Based on OpenStack 郭峰 (Golfen Guo) @教授也是浮云 golfen.guo@emc.com Cloud Platform and Application Lab, EMC Labs China © Copyright 2012 EMC Corporation. All rights reserved. 1
  2. 2. EMC Labs China Advanced Technology Research and Development University Collaboration Vision Big Data Lab Become an elite research and advanced technology institute Industry Cloud Infrastructure in China Standards Office and System Lab - Become the model for future EMC Labs Cloud Platform and worldwide Applications Lab IP Portfolio Development © Copyright 2012 EMC Corporation. All rights reserved. 2
  3. 3. Agenda • What is PaaS • CloudFoundry Overview • Elastic Architecture in CloudFoundry • Introduce to BOSH • CPI and OpenStack • Deploy PaaS with BOSH © Copyright 2012 EMC Corporation. All rights reserved. 3
  4. 4. What is PaaS? (from Search Cloud Computing) • Platform as a Service (PaaS) is a way to rent hardware, operating systems, storage and network capacity over the Internet. • The service delivery model allows the customer to rent virtualized servers and associated services for running existing applications or developing and testing new ones. RENT, not BUILD one! Virtual Server and Associated Service © Copyright 2012 EMC Corporation. All rights reserved. 4
  5. 5. How PaaS Benefit Us? Before: Now: © Copyright 2012 EMC Corporation. All rights reserved. 5
  6. 6. How PaaS Benefit Us? (Cont.) From Accelerating your Journey to Application Transformation, EMC World 2012 PaaS powered You Manage Traditional IT IaaS PaaS You Manage Applications Applications Applications Agility and Data Data Data Cost Savings Managed by Platform Managed by Platform Runtime You Manage Runtime Runtime Middleware Middleware Middleware O/S O/S O/S Virtualization Virtualization Virtualization Servers Servers Servers Storage Storage Storage Networking Networking Networking © Copyright 2012 EMC Corporation. All rights reserved. 6
  7. 7. Cloud Foundry – The Open PaaS © Copyright 2012 EMC Corporation. All rights reserved. 7
  8. 8. PaaS in Action… Another analogy from Mark Lucovsky, Every one knows, “Hello World”: $ cat hw.c #include <stdio.h> main() { printf(“Hello Worldn”); } $ cc hw.c; ./a.out © Copyright 2012 EMC Corporation. All rights reserved. 8
  9. 9. PaaS in Action... (Cont. ) “Hello World” in the Cloud: $ cat hw.rb require 'rubygems' require 'sinatra' $hits = 0 get '/' do $hits = $hits + 1 "Hello World - #{$hits}" end $ vmc push hw © Copyright 2012 EMC Corporation. All rights reserved. 9
  10. 10. Scale App On Demand Implement a Scalability “Hello World” in Cloud: Step 1: Scale instance to 10: $ vmc instances hw 10 Step 2: Change the codes: get '/' do $hits = $redis.incr(‘hits’) "Hello World - #{$hits}" Redis end Step 3: bind Redis service to App: $ vmc create-service redis –bind hw © Copyright 2012 EMC Corporation. All rights reserved. 10
  11. 11. Scale App On Demand(Cont.) From Cloud Foundry Launch Event, April, 2011 PaaS powered © Copyright 2012 EMC Corporation. All rights reserved. 11
  12. 12. Simplify Deployment [mysqld] user = foobar port = 3306 Before: basedir = /usr bind-address = 172.58.77.101 key_buffer = 16M thread_stack = 128K thread_cache_size = 8 … [nginx] http.include mime.types; default_type: application/octet-stream; Web App log_format: main ‘$remote_addr - $remote_user []…’ keepalive_timeout 65; [tomcat] <Connector redirectPort=‚8443‛ emptySessionPath…/> <bean id=‚sessionFactory‛ class=‚org.springframework…/> [frontend] dependencies: - mysqlclient - ruby files: - core/app/fe/**/* - core/common/**/* [blah] - blah blah blah © Copyright 2012 EMC Corporation. All rights reserved. 12
  13. 13. Simplify Deployment (Cont.) Now: # to target and login to cloud foundry vmc target http://api.cloudfoundry.com vmc login Web App # to create and boot the app for the first time vmc push myapp –instances 2 –mem 64M –path ../code # to create the database and bind it to the app vmc create-service mysql –name mydb –bind myapp # update live app with new code vmc update myapp –path ../code © Copyright 2012 EMC Corporation. All rights reserved. 13
  14. 14. First Touch CloudFoundry prompt> gem install vmc prompt> vmc target api.cloudfoundry.com prompt> vmc login prompt> vmc push Would you like to deploy from the current directory? [Yn] Yes Application Name: hello Application Deployed URL: 'hello.cloudfoundry.com'? hello-bob.cloudfoundry.com Detected a Sinatra Application, is this correct? [Yn] Yes Memory Reservation [Default:128M] (64M, 128M, 256M, 512M or 1G) (Press Enter to take default) Would you like to bind any services to 'hello'? [yN]: No Uploading Application: Checking for available resources: OK Packing application: OK Uploading (0K): OK Push Status: OK Staging Application: OK Starting Application: OK © Copyright 2012 EMC Corporation. All rights reserved. 14
  15. 15. First Touch CloudFoundry(Cont.) Upload your app Memory of each instance Change served instances Your apps deployed Start, stop, update, restart Services of current app Your all created services Information of app © Copyright 2012 EMC Corporation. All rights reserved. 15
  16. 16. PaaS Architecture Pattern MySQL RabbitMQ MongoDB Redis © Copyright 2012 EMC Corporation. All rights reserved. 16
  17. 17. PaaS Architecture Pattern (Cont. ) © Copyright 2012 EMC Corporation. All rights reserved. 17
  18. 18. PaaS Architecture Pattern (Cont. ) © Copyright 2012 EMC Corporation. All rights reserved. 18
  19. 19. Conclusion Abstract to three layers: • Routers for finding right endpoint of Apps • Runtime for Apps • Services provided by platform, consumed by Apps © Copyright 2012 EMC Corporation. All rights reserved. 19
  20. 20. The Keys of Design… • Elastic • Failover/System Robust • Resource Recycling © Copyright 2012 EMC Corporation. All rights reserved. 20
  21. 21. Elastic Architecture in CloudFoundry Sends droplet Design principals: heart beats and exit messages 1. Each components can be run standalone; Router 2. Each components can be scale-out, and notify the peersand with Router Registers message; Registers and unregisters unregisters 3. The components communicate only with message or RESTful API. Routes droplet Routes REST API requests requests Droplet change notifications Self-government and LooseController Cloud Couples : Stop, Find) Droplet Cloud Orchestrates Health Manager start/stop Controller (Start, Droplet Execution requests • Easy to add new components. eg Stager, UAA, ACM…; Agent (DEA) • Easy to evolve each component. eg. CC_ng, Router v2… Periodically scans Persists droplets for consistency and provisioned Guest applications Advertise services consume Cloud Service Controller Provision and Database unprovision Service "A" Provision Service and "A" Provisioning Agent unprovision © Copyright 2012 EMC Corporation. All rights reserved. 21
  22. 22. Elastic Architecture in CloudFoundry Sends droplet A request comes… heart beats and exit messages Router Router Registers and Registers and unregisters unregisters Routes droplet Routes REST API requests requests Droplet change notifications Droplet Cloud Controller Orchestrates Health Manager start/stop Cloud Controller (Start, Stop, Find) Droplet Execution requests Agent (DEA) Periodically scans Persists droplets for consistency and provisioned Guest applications Advertise services consume Cloud Service Controller Provision and Database unprovision Service "A" Provision Service and "A" Provisioning Agent unprovision © Copyright 2012 EMC Corporation. All rights reserved. 22
  23. 23. Pluggable Runtime Support Refers to https://github.com/cloudfoundry/vcap-staging • stager -> vcap-staging klass = StagingPlugin.load_plugin_for(plugin_name) plugin = klass.from_file(config_path) plugin.stage_application App Stager StagingPlugin Start Stop Script Script Server PHP Rails3 Java_Web Play … extends StagingPlugin © Copyright 2012 EMC Corporation. All rights reserved. 23
  24. 24. Pluggable Runtime Support (Cont.) So what we need to do is… • Extends Class StagingPlugin in Common.rb Line3 ~ Line 62, 59 lines of codes to support PHP.  © Copyright 2012 EMC Corporation. All rights reserved. 24
  25. 25. Pluggable Runtime Support (Cont.) Key methods to rewrite: • stage_application • start_command • startup_script • stop_command • stop_script © Copyright 2012 EMC Corporation. All rights reserved. 25
  26. 26. Pluggable Services Support Refers to a nice presentation by Nicholas Kushmerick Cloud Foundry Services in last forum: • Service advertisement • Service Gateway -> Cloud Controller • POST /services/v1/offerings • DELETE /services/v1/offerings/:label • Instance management • Cloud Controller -> Service Gateway • Provision: POST /gateway/v1/configurations • Bind: POST /gateway/v1/configurations/:id/handles • Unbind: DELETE /gateway/v1/configurations/:id/handles/:handle • Unprovision: DELETE /gateway/v1/configurations/:id © Copyright 2012 EMC Corporation. All rights reserved. 26
  27. 27. But … • Modular Design • Version Tolerance • Flexible Runtime/Service • Elastic Architecture Trade Off • Many kinds of nodes • Many nodes each kind Complex deployment process like other distribution system © Copyright 2012 EMC Corporation. All rights reserved. 27
  28. 28. Practical problem at CloudFoundry.com 40+ unique node types 75+ unique software packages 500-5,000 VMs 2x/week cf.com updates 24*7*365 non-stop operation No-downtime deployments Reliable ,robust ,repeatable deployments ,updates , capacity adjustments Small teams manage many instances © Copyright 2012 EMC Corporation. All rights reserved. 28
  29. 29. How to deploy CloudFoundry? © Copyright 2012 EMC Corporation. All rights reserved. 29
  30. 30. CloudFoundry BOSH CloudFoundry BOSH is an open source tool-chain for release engineering, deployment, and lifecycle management of large scale distributed services – Prescriptive way of creating releases and managing systems and services – It is not a collection of shell scripts, not a pile of Perl Built to deploy and manage production-class, large scale clusters – Production grade Cloud Foundry clusters: 500+ VMs, 40+ jobs, 75+ packages – Multi-node, multi-tier, complex clusters Built for DevOps usage and scale by a crack team of veterans – A project, not a product: command line interface, YAML, etc. – Continuous improvement, iterative development, rough edges https://github.com/cloudfoundry/bosh © Copyright 2012 EMC Corporation. All rights reserved. 30
  31. 31. CloudFoundry BOSH (Cont.) Built from the need to operate cloudfoundry.com – Over 40 different types of VMs – Hundreds of running instances of VMs – Pushing at least 2 changes per week End-to-end management – Release engineering – Deployment – Lifecycle management Generic solution – Any service – Any cloud – Any operating system © Copyright 2012 EMC Corporation. All rights reserved. 31
  32. 32. BOSH Architecture 1. Upload Stemcell 1. CLI -> Director 2. Director -> Blobstore 2. Upload Release 1. CLI -> Director 2. Director -> Blobstore 3. Deploy 1. CLI -> Director 2. Director -> A 3. Agent -> B 4. Agent -> C © Copyright 2012 EMC Corporation. All rights reserved. 32
  33. 33. BOSH Concepts Stemcell – VM template – BOSH Agent – IaaS Plugin Release – Jobs Job – Packages – Templates (scripts, confs) – Monitoring Package – Source/blobs – Dependencies – Packaging (scripts) © Copyright 2012 EMC Corporation. All rights reserved. 33
  34. 34. IaaS Neutral vSphere: battle tested implement AWS: code complete Cloud Foundry BOSH Cloud Provider Interface(CPI) OpenStack: testable release https://github.com/piston/ openstack-bosh-cpi © Copyright 2012 EMC Corporation. All rights reserved. 34
  35. 35. Cloud Provider Interface Stemcell – create_stemcell (image, cloud_properties) – delete_stemcell (stemcell) VM – create_vm (agent_id, stemcell, resource_pool, networks, disk_locality, env) – delete_vm (vm) – reboot_vm (vm) – configure_networks (vm, networks) Disk – create_disk (size, vm_locality) – delete_disk (disk) – attach_disk (vm, disk) – detach_disk (vm, disk) © Copyright 2012 EMC Corporation. All rights reserved. 35
  36. 36. Cloud Provider Interface (Cont.) For OpenStack Stemcell – create_stemcell … – delete_stemcell Cloud Provider Interface VM – create_vm – delete_vm – reboot_vm OpenStack VM VM Image Service VM – configure_networks VM VM Disk – create_disk OpenStack – delete_disk Compute – attach_disk – detach_disk © Copyright 2012 EMC Corporation. All rights reserved. 36
  37. 37. Deploy PaaS with BOSH Sends droplet heart beats and exit messages Router Router Registers and Registers and unregisters unregisters CLI Routes REST API Routes droplet requests requests Droplet change notifications Droplet Cloud Controller Orchestrates Health Manager start/stop Cloud Controller (Start, Stop, Find) Droplet Execution requests Agent (DEA) Periodically scans Persists droplets for consistency and provisioned Guest applications Advertise services consume Cloud Service Controller Provision and Database unprovision Service "A" Provision Service and "A" Provisioning Agent unprovision BOSH IaaS © Copyright 2012 EMC Corporation. All rights reserved. 37
  38. 38. Deployments Release Network Resource pools Jobs Properties Update concurrency Compilation workers Cloud properties © Copyright 2012 EMC Corporation. All rights reserved. 38
  39. 39. Deployments for CloudFoundy Cloudfoundry.yml name: cloudfoundry release: name: cloudfoundry version: 89.1-dev compilation: workers: 4 network: default cloud_properties: ram: 1024 disk: 2048 cpu: 2 update: canaries: 1 canary_watch_time: 3000-90000 update_watch_time: 3000-90000 max_in_flight: 2 max_errors: 1 © Copyright 2012 EMC Corporation. All rights reserved. 39
  40. 40. Deployments for CloudFoundy (Cont.) Cloudfoundry.yml networks: - name: default subnets: - static: - 192.168.2.50 - 192.168.2.89 range: 192.168.2.0/24 gateway: 192.168.2.1 dns: - 10.254.174.10 cloud_properties: name: PrivateNetwork - name: lb subnets: - static: - 192.168.2.90 - 192.168.2.99 range: 192.168.2.0/24 gateway: 192.168.2.1 dns: - 10.254.174.10 cloud_properties: name: PrivateNetwork © Copyright 2012 EMC Corporation. All rights reserved. 40
  41. 41. Deployments for CloudFoundy (Cont.) Cloudfoundry.yml resource_pools: - name: infrastructure network: default size: 29 stemcell: name: bosh-stemcell version: 0.6.2 cloud_properties: ram: 256 disk: 2048 cpu: 1 env: bosh: password: © Copyright 2012 EMC Corporation. All rights reserved. 41
  42. 42. Deployments for CloudFoundy (Cont.) Cloudfoundry.yml jobs: - name: cloud_controller template: cloud_controller instances: 1 resource_pool: infrastructure networks: - name: default static_ips: - 192.168.2.60 - name: nats template: nats instances: 1 resource_pool: infrastructure networks: - name: default static_ips: - 192.168.2.52 © Copyright 2012 EMC Corporation. All rights reserved. 42
  43. 43. Deployments(CloudFoundy) Cloudfoundry.yml properties: domain: cflocal.com env: {} networks: apps: default management: default nats: user: nats password: aaa3ij3122 address: 192.168.2.52 port: 4222 © Copyright 2012 EMC Corporation. All rights reserved. 43
  44. 44. Use Case bosh deployment bosh target cf cf.yml Bug report to Dev git pull Run bosh upload release Done! bosh deploy © Copyright 2012 EMC Corporation. All rights reserved. 44
  45. 45. Acknowledgments VMware China R&D Center Network & Information Center, Shanghai Jiao Tong Univ. CloudFoundry Community Piston Community http://www.cloudfoundry.org https://github.com/piston/open stack-bosh-cpi © Copyright 2012 EMC Corporation. All rights reserved. 45
  46. 46. Q&A © Copyright 2012 EMC Corporation. All rights reserved. 46
  47. 47. Backup Slides © Copyright 2012 EMC Corporation. All rights reserved. 47
  48. 48. Management Path– vmc info db cloud controller nats health manager router dea service app app © Copyright 2012 EMC Corporation. All rights reserved. 48
  49. 49. Deployment Path– vmc push db cloud controller nats health manager router dea service app app © Copyright 2012 EMC Corporation. All rights reserved. 49
  50. 50. Data Path– Client Request db cloud controller nats health manager router dea service app app © Copyright 2012 EMC Corporation. All rights reserved. 50
  51. 51. Evolving Cloud Foundry - Kernel uaa stager db Package cloud controller cache v2 v2 nats health manager v2 v2 v2 router v2 v2 warden dea caldecott service app app © Copyright 2012 EMC Corporation. All rights reserved. 51
  52. 52. How to write a custom service? • Public API for advertising services and managing service instances Cloud • Endpoints: Controll – Cloud Controller er – Service Gateway (one per service) • REST / JSON / HTTP(S) MySQL Gatewa MongoD y B Gatewa y © Copyright 2012 EMC Corporation. All rights reserved. 52
  53. 53. How to write a custom service? (Cont.) Step 1: Service advertisement Service Gateway -> Cloud Controller, two methods:  POST /services/v1/offerings  DELETE /services/v1/offerings/:label :label => 'mysql-5.1' :url => 'http://12.34.56.78:4321', :plans => ['free', 'bronze', 'silver', 'gold'] :tags => ['mysql', 'mysql-5.1', 'database'] :active => true, :description => 'MySQL database service' :acls => { :wildcards => '*@vmware.com', :plans => { :bronze => { :users => ['joe@vmware.com', 'jane@vmware.com'] } } } © Copyright 2012 EMC Corporation. All rights reserved. 53
  54. 54. How to write a custom service? (Cont.) Step 2: Instance management Cloud Controller -> Service Gateway, four methods:  Provision: POST /gateway/v1/configs  Bind: POST /gateway/v1/configs/:id/handles  Unbind: DELETE /gateway/v1/configs/:id/handles/:handle  Unprovision: DELETE /gateway/v1/configs/:id © Copyright 2012 EMC Corporation. All rights reserved. 54
  55. 55. Reference implementation Develope A vmc create-service postgresql r vmc, STS B POST /services/v1/configurations Cloud Controller C G H {host: 12.34.56.78, port: 3456, POST /gateway/v1/configurations VCAP_SERVICES = [postgres: db: abc123, user: pqr456} {host: 12.34.56.78, port: 3456, db: abc123, user: pqr456}] Service Gateway F D Private API {host: 12.34.56.78, port: 3456, App NATS: provision SELECT * db: abc123, user: pqr456} E FROM FOO CREATE DATABASE abc123 CREATE ROLE pqr456 I GET /foo/bar Service Node (eg, PostgreSQL) Service (eg, PostgreSQL) host 12.34.56.78 End Users © Copyright 2012 EMC Corporation. All rights reserved. 55
  56. 56. For legacy service – Service Broker • Cloud Foundry users may already have existing services • Legacy database that hasn’t / won’t / can’t be moved CloudFoundry.com • Services not yet supported • Service Broker exposes an arbitrary legacy service instance to Cloud Foundry so that it can be used just like any other instance © Copyright 2012 EMC Corporation. All rights reserved. 56
  57. 57. For legacy service – Service Broker (Cont.) B D register hrdb {host: 87.65.43.21, port: 6543, db: def123, user: stu456} vmc create-service hrdb vmc, STS Cloud Controller Service Broker Admin Tools E H POST /services/v1/configurations VCAP_SERVICES = [hrdb: POST /gateway/v1/configurations G {host: 87.65.43.21, port:6543, db: def123, user: stu456}] port: 6543, {host: 87.65.43.21, C F POST /broker/v1/configuration db: def123, user: stu456} Service Gateway App Connecti on Details Service Broker A Core Service CREATE DATABASE def123 (eg, PostgreSQL) CREATE USER stu456 SELECT * FROM FOO Brokered Service host 12.34.56.78 (eg, Oracle DB) GET /foo/bar I © Copyright 2012 EMC Corporation. All rights reserved. 57

Editor's Notes

  • 为什么写脚本繁琐?一个实际的PaaS平台上,遇到的实际的问题。很多很多原因造成了用脚本配置的复杂性。CloudFoundry 越来越复杂。更多的node type和software packages.CloudFoundry本身就很复杂,最微小的集群也很麻烦。节点很多。需要管理VM。雪上加霜。更新频繁,不间断服务。写脚本的时候不能出问题。测试环境的脚本和线上的还不一样。不断的调整,调整容量。纵向扩展和软件关系比较小,横向比较大。团队很小CloudFoundry的理想是成为PaaS平台的Linux。部署,运维成为麻烦阻碍CloudFoundry成为PaaS平台的Linux绊脚石,自己吃苦就算了,不能让用户也写繁琐的脚本,必须要解决这个问题。
  • 回顾:我们曾经如何部署CouldFoundry。使用脚本,CloudFoundry提供了一个安装脚本。使用部署工具,CloudFoundry以前是使用Chef使用这些工具有一些不便的地方,就是要写脚本对于CloudFoundry来说,写脚本太繁琐了
  • 前面说了 写脚本的方式太繁琐,有没有一个办法来解决上面的问题?BOSH自我介绍今天的主题是BOSH的架构和实践。BOSH是CloudFoundry的部署运维工具,在今年4月满周岁的正式发布。有什么问题随时打断。BOSH是胡扯。是BOSH Outer Shell的首字母缩写。BOSH不是一个CloudFoundry的组件。Initially the B stood for a code name which we deprecated soon after. For the compleetepictur, the Cloud Foundry PaaS (vcap) is the inner shell. Bosh是一个工具。可以打包,部署,运维 分布式系统。不仅仅是部署,还包括管理。不仅仅是CloudFoundry,所有的分布式系统。使用他,发布工程师打一个包,部署工程师写一个配置文件,一条命令部署到分布式系统,运维也是改改配置,一条命令不是简单的一组脚本,他有很多功能是脚本很难完成的,比如跨Cloud。Repeatable。复杂:环境复杂。大集群。多节点。多软件。多任务。简单:使用简单。只要会简单的CLI,YAML配置就可以不断持续的更新
  • 背景系统架构中模块很多。很多模块,各有关系,写脚本乱规模很大。执行比较困难。出错什么的处理起来费力。变化很快。不是一劳永逸,扩容更新很频繁。功能,解决方案。对软件提供一个从头到脚的运维工具发布。打包成一个Release。部署。使用Bosh deploy。运维。使用修改配置。Bosh log,ssh,deploy之类。通用的不限于CloudFoundry, 任何分布式系统都可以。最适合的是系统平台类。比如一个云服务。不限于vmware。现在Vmware,AWS,OpenStack都支持不限操作系统,任意操作系统都是支持的。现在主要是Linux,版本是Ubuntu10.4
  • 对 BOSH 有了一个大致的印象后。看一下BOSH的架构。1.看圈2.但我们部署一个应用的时候。上传一个模板。(模板就是虚拟机模板,里面有Agent和虚拟机的插件)通过CLI告诉Director说我要上传一个模板Director把模板送到BlobStore里面上传一个Release通过CLI告诉Director说我要上传一个ReleaseRelease会下载一些依赖包。Director把Release送到BlobStore里面部署通过CLI告诉Director说我要部署Director将包从BlobStore取出编译编译完放回去通过A创建一个VM。使用Stemcell作为模板通过B。VM上的Agent部署这个应用其他流程
  • 刚刚提到了一些的概念。StemCell,Release解释 StemCell是集成了BOSH_Agent的虚拟机模板。给CloudFoundry用的stemcell是一个ubunutu的版本。可以使用CLI来上传。BOSH Director用他来创建VM。当创建Vm的时候,要传入Network和存储的配置,还有Blobstroe的位置。Release是Job的集合。可以理解为一个文件夹,里面什么都有。这个文件夹是发布工程师搞的。Job就是一个服务。比如Mysql,可能有多个实例。Job包含Package+运维的脚本. 比如我一个Myql的Job里面可以有两个package,一个是MysqlServer还有一个是Mysql的Client.Job还有配置文件和启动的脚本。可以让一个Job跑多个进程。PackageSource/blobsPackaging Script编译期
  • BOSH在SHELL外面,VM 在 SHELL里面。BOSH是如何来实现跨虚拟机平台的呢?是通过CPI。将一些常用的虚拟机操作抽象出来,形成一套简单的接口,然后再分别加以实现。vSphere:真刀真枪的实现,支持4.2和5.0两个版本。有成千上万的部署使用到了。AWS:逐步完善,已经可以使用。在论坛上看到。有很多人已经部署过了。OpenStack:积极的进展。有Vmware和合作伙伴piston cloud开发。这个公司是个专门做OpenStack的公司。现在关于OpenStack有越来越多的资料。已经有了可以测试的版本。piston cloud希望将这部被代码集成在自己的企业版本里面,作为新项目提交到OpenStack的官方外围。https://github.com/piston/openstack-bosh-cpihttps://github.com/drnic/bosh-getting-started/blob/master/create-a-bosh/creating-a-micro-bosh-from-stemcell-openstack.md
  • https://github.com/cloudfoundry/bosh/blob/master/cpi/lib/cloud.rb.CPI非常的精简。上面列出的就是全部,没有省略。当配置一台虚拟机的时候。Stemcell是模板相关的。可以create来上传一个模板。VM是VM相关的。可以create_vm来create一个vm.需要传入一个stemcell作为参数,虚拟机就是从那个模板clone出来的通过configure_network配置网卡。Disk是存储相关的。通过create创建,attach来连接到VM上。Create disk的时候在哪个存储上?最后可以通过reboot_vm来重启动vm。
  •    @openstack=Fog::Compute.new(openstack_params)      @glance=Fog::Image.new(openstack_params)http://fog.io/0.8.1/compute/OpenStack Image Service Developer Guide API 1.0Stemcellcreate_stemcell(image, cloud_properties) @glance.images.createdelete_stemcell(stemcell) @openstack.images.get(stemcell_id) .destroyVMcreate_vm(agent_id, stemcell, resource_pool, networks, disk_locality, env) @openstack.images.find { |i| i.id ==stemcell_id }         server =@openstack.servers.create(server_params)delete_vm(vm) = @openstack.servers.get(server_id)  server.destroyreboot_vm(vm) openstack.servers.get(server_id)  soft_reboot(server)configure_networks(vm, networks)@openstack.servers.get(server_id) network_configurator.configure(@openstack, server)Diskcreate_disk(size, vm_locality)  volume = @openstack.volumes.create(volume_params)delete_disk(disk) @openstack.volumes.get(disk_id) destroyattach_disk(vm, disk) volume.attach(server.id, dev_name)detach_disk(vm, disk) volume.detach(server.id, volume.id)
  • 眼见为实,耳听为虚,直接来实践。部署一个CloudFoundry集群CloudFoundry本身很复杂。就不深入结构。有哪些package ,哪些Jobs,哪些release灌入概念
  • Stemcells and Packages是静态的,可以是别人已经发布好的。需要使用Deployment配置文件将他们和我们自己的环境结合在一起。配置文件 主要 是这样的。Release:名称版本Network:网络环境。网卡,ip访问Resource pool: VM的池,默认的CPU和内存,磁盘大小。Job:希望使用的Job:实例的个数,网络和存储,机器配置 自定义。部署的时候替换成Properties。每一个Job可以定义一种组件,如Mysql,NighxProperties:填充模板的变量

×