OpenStack使用Bosh部署CloudFoundry(五)—使用Bosh部署CloudFoundry

目录(?)[-]

  1. 调整虚拟机存储配置
  2. 下载并编译CloudFoundry发布包
  3. 切换bosh target到Bosh的Director并创建新用户
  4. 上传release和stemcell到Bosh中
  5. 创建并配置用于部署CloudFoundry的Manifest文件
  6. 使用CF客户端管理CloudFoundry运行环境

版本说明:

CloudFoundry:V2版本-v149+(本文后续章节中的Manifest适用于149+版本的CF Release)

OpenStack:Grizzly版本+nova-network

CloudFoundry部署交流QQ群:176302388

CloudFoundry目前官方的版本为V2版,release最新发布为149,不过CloudFoundry在GitHub上的仓库代码贡献非常频繁,一般只要提出有BUG,很快就会有修改并提交,所以,最好的部署方式是直接下载源码,创建dev版的release进行部署,当然,也可以直接使用官方发布的release进行打包部署,本文中使用149.1-dev进行打包部署,如果要使用官方release,指定release路径即可,如:bosh create release release/cf-149.yml。

注意:本文中的示例Manifest仅适用于149+版本的release。


1、调整虚拟机存储配置

默认情况下blobstore/0虚拟机中/var/vcap/store的存储空间比较小,而后边上传用于部署CloudFoundry的Stemcell包和Release包时,会因为存储空间不足导致错误,所以这里先增加/var/vcap/store的挂载空间,防止发生错误。

具体步骤参看文章:http://blog.csdn.net/tiger435/article/details/8808623#t8。

说明:本环境配置文件中的所有通过Stemcell创建的虚拟机的登陆账户密码为“root/c1oudc0w”或者“vcap/c1oudc0w”

注意:即使配置挂载空间后,以后重启blobstore的虚拟机的时候一定记得再次挂载,或者可以修改为开机挂载,本人就是忘记该步骤,导致重启虚拟机后,后边部署cf-service-release时出现莫名其妙找不到package的错误,折磨几个小时。

2、下载并编译CloudFoundry发布包

依次执行以下命令从GitHub获取并更新代码

[plain]  view plain copy
  1. root@bosh-cli:~# mkdir -p ~/src/cloudfoundry  
  2. root@bosh-cli:~# cd ~/src/cloudfoundry  
  3. root@bosh-cli:~/src/cloudfoundry# git clone -b release-candidate git://github.com/cloudfoundry/cf-release.git  
  4. root@bosh-cli:~/src/cloudfoundry# cd cf-release  
  5. root@bosh-cli:~/src/cloudfoundry/cf-release# ./update  

下载并更新完毕之后,执行以下命令创建release包,这是一个相当漫长的过程,中间还会发生多次中断,只要重新执行bosh create release --force即可:

说明:bosh create release --force 是使用最新的CloudFoundry源码创建release-dev包,可能会存在一些奇怪的BUG或者错误、问题,好处就是使用这种方式构建release-dev包,下次代码更新后,再进行打包速度会比较快。若过程中出现问题,可以使用经过测试发布的release包,打包方式:bosh create release releases/cf-149.yml,会在releases目录下生成一个tgz的压缩包,之后执行bosh upload releases/cf-149.tgz上传release包即可。

[plain]  view plain copy
  1. root@bosh-cli:~/src/cloudfoundry/cf-release# bosh create release --force  
  2.   
  3. ....  
  4.   
  5. Building jobs  
  6. -------------  
  7. Building health_manager_next...  
  8.   Final version:   NOT FOUND  
  9.   Dev version:     NOT FOUND  
  10.   Generating...  
  11.   Generated version 7.1-dev  
  12.   
  13. Building dashboard...  
  14.   Final version:   Downloading `dashboard (10)'...  
  15.   
  16. Building ccdb_postgres...  
  17.   Final version:   Downloading `ccdb_postgres (7)'...  
  18.   
  19. Building gorouter...  
  20.   Final version:   Downloading `gorouter (2)'...  
  21.   
  22. Building dea_next...  
  23.   Final version:   NOT FOUND  
  24.   Dev version:     NOT FOUND  
  25.   Generating...  
  26.   Generated version 12.1-dev  
  27.   
  28. Building collector...  
  29.   Final version:   NOT FOUND  
  30.   Dev version:     NOT FOUND  
  31.   Generating...  
  32.   Generated version 6.1-dev  
  33.   
  34. Building uaa...  
  35.   Final version:   NOT FOUND  
  36.   Dev version:     NOT FOUND  
  37.   Generating...  
  38.   Generated version 27.1-dev  
  39.   
  40. Building syslog_aggregator...  
  41.   Final version:   NOT FOUND  
  42.   Dev version:     NOT FOUND  
  43.   Generating...  
  44.   Generated version 10.1-dev  
  45.   
  46. Building login...  
  47.   Final version:   NOT FOUND  
  48.   Dev version:     NOT FOUND  
  49.   Generating...  
  50.   Generated version 11.1-dev  
  51.   
  52. Building debian_nfs_server...  
  53.   Final version:   FOUND LOCAL  
  54.   
  55. Building nats...  
  56.   Final version:   NOT FOUND  
  57.   Dev version:     NOT FOUND  
  58.   Generating...  
  59.   Generated version 10.1-dev  
  60.   
  61. Building postgres...  
  62.   Final version:   Downloading `postgres (4)'...  
  63.   
  64. Building cloud_controller_ng...  
  65.   Final version:   NOT FOUND  
  66.   Dev version:     NOT FOUND  
  67.   Generating...  
  68.   Generated version 7.1-dev  
  69.   
  70.   
  71. Building release  
  72. ----------------  
  73.   
  74. Generating manifest...  
  75. ----------------------  
  76. Writing manifest...  
  77.   
  78. Release summary  
  79. ---------------  
  80. Packages  
  81. +---------------------+----------+-------------+  
  82. | Name                | Version  | Notes       |  
  83. +---------------------+----------+-------------+  
  84. | git                 | 1        |             |  
  85. | nginx               | 9        |             |  
  86. | ruby                | 8        |             |  
  87. | health_manager_next | 18       |             |  
  88. | dashboard           | 14       |             |  
  89. | libyaml             | 1        |             |  
  90. | rootfs_lucid64      | 1        |             |  
  91. | insight_agent       | 2        |             |  
  92. | ruby_next           | 3        |             |  
  93. | gorouter            | 4.1-dev  | new version |  
  94. | dea_next            | 16.1-dev | new version |  
  95. | collector           | 8.1-dev  | new version |  
  96. | uaa                 | 24.1-dev | new version |  
  97. | golang              | 2        |             |  
  98. | warden              | 26.1-dev | new version |  
  99. | mysqlclient         | 3        |             |  
  100. | syslog_aggregator   | 4        |             |  
  101. | libpq               | 5        |             |  
  102. | login               | 13.1-dev | new version |  
  103. | dea_jvm             | 4        |             |  
  104. | buildpack_cache     | 1.1-dev  | new version |  
  105. | debian_nfs_server   | 3        |             |  
  106. | nats                | 8        |             |  
  107. | postgres            | 4        |             |  
  108. | sqlite              | 3        |             |  
  109. | imagemagick         | 2        |             |  
  110. | cloud_controller_ng | 13.1-dev | new version |  
  111. | common              | 5        |             |  
  112. +---------------------+----------+-------------+  
  113.   
  114. Jobs  
  115. +---------------------+----------+-------------+  
  116. | Name                | Version  | Notes       |  
  117. +---------------------+----------+-------------+  
  118. | health_manager_next | 7.1-dev  | new version |  
  119. | dashboard           | 10       |             |  
  120. | ccdb_postgres       | 7        |             |  
  121. | gorouter            | 2        |             |  
  122. | dea_next            | 12.1-dev | new version |  
  123. | collector           | 6.1-dev  | new version |  
  124. | uaa                 | 27.1-dev | new version |  
  125. | syslog_aggregator   | 10.1-dev | new version |  
  126. | login               | 11.1-dev | new version |  
  127. | debian_nfs_server   | 7        |             |  
  128. | nats                | 10.1-dev | new version |  
  129. | postgres            | 4        |             |  
  130. | cloud_controller_ng | 7.1-dev  | new version |  
  131. +---------------------+----------+-------------+  
  132.   
  133. Jobs affected by changes in this release  
  134. +---------------------+----------+  
  135. | Name                | Version  |  
  136. +---------------------+----------+  
  137. | health_manager_next | 7.1-dev  |  
  138. | dea_next            | 12.1-dev |  
  139. | collector           | 6.1-dev  |  
  140. | uaa                 | 27.1-dev |  
  141. | syslog_aggregator   | 10.1-dev |  
  142. | login               | 11.1-dev |  
  143. | nats                | 10.1-dev |  
  144. | cloud_controller_ng | 7.1-dev  |  
  145. | gorouter            | 2        |  
  146. +---------------------+----------+  
  147.   
  148. Release version: 149.1-dev  
  149. Release manifest: /root/src/cloudfoundry/cf-release/dev_releases/cf-release-149.1-dev.yml  

3、切换bosh target到Bosh的Director并创建新用户

[plain]  view plain copy
  1. root@bosh-cli:~/src/cloudfoundry/cf-release# bosh target https://10.68.19.132:25555  
  2. Target set to `bosh'  
  3. root@bosh-cli:~/src/cloudfoundry/cf-release# bosh login  
  4. Your username: admin  
  5. Enter password: *****  
  6. Logged in as `admin'  
  7. root@bosh-cli:~/src/cloudfoundry/cf-release# bosh create user  
  8. Enter new username: venusource  
  9. Enter new password: **********  
  10. Verify new password: **********  
  11. User `venusource' has been created  
  12. root@bosh-cli:~/src/cloudfoundry/cf-release# bosh login  
  13. Your username: venusource  
  14. Enter password: **********  
  15. Logged in as `venusource'  

4、上传release和stemcell到Bosh中

上传Stemcell和部署Bosh的时候使用的是同一个Stemcell:

[plain]  view plain copy
  1. root@bosh-cli:~/src/cloudfoundry/cf-release# bosh upload stemcell ~/bosh-workspace/stemcells/<span style="font-family: Consolas, 'Courier New', Courier, mono, serif; line-height: 18px;">b</span>osh-stemcell-latest-openstack-kvm-ubuntu.tgz  
  2.   
  3. Verifying stemcell...  
  4. File exists and readable                                     OK  
  5. Using cached manifest...  
  6. Stemcell properties                                          OK  
  7.   
  8. Stemcell info  
  9. -------------  
  10. Name:    bosh-stemcell  
  11. Version: 776  
  12.   
  13. Checking if stemcell already exists...  
  14. No  
  15.   
  16. Uploading stemcell...  
  17.   
  18. latest-bosh-s: 100% |oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo| 251.3MB  11.0MB/s Time: 00:00:22  
  19.   
  20. Director task 1  
  21.   
  22. Update stemcell  
  23.   extracting stemcell archive (00:00:12)  
  24.   verifying stemcell manifest (00:00:00)  
  25.   checking if this stemcell already exists (00:00:00)  
  26.   uploading stemcell bosh-stemcell/776 to the cloud (00:02:05)  
  27.   save stemcell bosh-stemcell/776 (4e433167-acf2-41b0-b691-934684a63e52) (00:00:00)  
  28. Done                    5/5 00:02:17  
  29.   
  30. Task 1 done  
  31. Started         2013-12-17 07:03:06 UTC  
  32. Finished        2013-12-17 07:05:23 UTC  
  33. Duration        00:02:17  
  34.   
  35. Stemcell uploaded and created  
上传Release到Bosh:
[plain]  view plain copy
  1. root@bosh-cli:~/src/cloudfoundry/cf-release# bosh upload release  
  2.   
  3. ....  
  4.   
  5. Release has been created  
  6.   cf-release/149.1-dev (00:00:00)  
  7. Done                    1/1 00:00:00  
  8.   
  9. Task 2 done  
  10. Started         2013-12-18 01:59:30 UTC  
  11. Finished        2013-12-18 02:02:20 UTC  
  12. Duration        00:02:50  
  13.   
  14. Release uploaded  

验证下Stemcell和Release是否正常:

[plain]  view plain copy
  1. root@bosh-cli:~# bosh releases  
  2.   
  3. +------------+------------+-------------+  
  4. | Name       | Versions   | Commit Hash |  
  5. +------------+------------+-------------+  
  6. | cf-release | 149.1-dev* | 27784f08    |  
  7. +------------+------------+-------------+  
  8. (*) Currently deployed  
  9. (+) Uncommitted changes  
  10.   
  11. Releases total: 3  
  12. root@bosh-cli:~# bosh stemcells  
  13.   
  14. +---------------------------+---------+--------------------------------------+  
  15. | Name                      | Version | CID                                  |  
  16. +---------------------------+---------+--------------------------------------+  
  17. | bosh-openstack-kvm-ubuntu | 1478    | 316501e1-482d-472d-9fd9-b71a7b1223ee |  
  18. +---------------------------+---------+--------------------------------------+  
  19.   
  20. Stemcells total: 1  

5、创建并配置用于部署CloudFoundry的Manifest文件

从GitHub中获取模板文件:

[plain]  view plain copy
  1. root@bosh-cli:~/src/cloudfoundry/cf-release# cd ~/bosh-workspace/deployments/  
  2. root@bosh-cli:~/bosh-workspace/deployments# vi cf-149.yml  

下边给我本环境中配置后的Manifest.yml文件作为参考:

[plain]  view plain copy
  1. ---  
  2. name: cf  
  3. director_uuid: 785aa0a6-87c7-4452-a862-c118afc90b37  
  4.   
  5. releases:  
  6.  - name: cf-release  
  7.    version: latest  
  8.   
  9. networks:  
  10. - name: floating  
  11.   type: vip  
  12.   cloud_properties: {}  
  13. - name: default  
  14.   type: dynamic  
  15.   cloud_properties:  
  16.     security_groups:  
  17.     - default  
  18.   
  19. update:  
  20.   canaries: 1  
  21.   canary_watch_time: 30000-60000  
  22.   update_watch_time: 30000-60000  
  23.   max_in_flight: 4  
  24.   
  25. compilation:  
  26.   workers: 6  
  27.   network: default  
  28.   reuse_compilation_vms: true  
  29.   cloud_properties:  
  30.     instance_type: v1.medium  
  31.   
  32. resource_pools:  
  33.   - name: small  
  34.     network: default  
  35.     size: 4  
  36.     stemcell:  
  37.       name: bosh-openstack-kvm-ubuntu  
  38.       version: latest  
  39.     cloud_properties:  
  40.       instance_type: v1.small  
  41.   
  42.   - name: medium  
  43.     network: default  
  44.     size: 0  
  45.     stemcell:  
  46.       name: bosh-openstack-kvm-ubuntu  
  47.       version: latest  
  48.     cloud_properties:  
  49.       instance_type: v1.medium  
  50.   
  51. jobs:  
  52.   - name: data  
  53.     release: cf-release  
  54.     template:  
  55.       - postgres  
  56.       - debian_nfs_server  
  57.     instances: 1  
  58.     resource_pool: small  
  59.     persistent_disk: 4096  
  60.     networks:  
  61.     - name: default  
  62.       default:  
  63.       - dns  
  64.       - gateway  
  65.     properties:  
  66.       db: databases  
  67.   
  68.   - name: core  
  69.     release: cf-release  
  70.     template:  
  71.       - syslog_aggregator  
  72.       - nats  
  73.       - health_manager_next  
  74.       - uaa  
  75.     instances: 1  
  76.     resource_pool: small  
  77.     networks:  
  78.     - name: default  
  79.       default:  
  80.       - dns  
  81.       - gateway  
  82.   
  83.   - name: api  
  84.     release: cf-release  
  85.     template:  
  86.       - cloud_controller_ng  
  87.       - gorouter  
  88.     instances: 1  
  89.     resource_pool: small  
  90.     networks:  
  91.     - name: default  
  92.       default:  
  93.       - dns  
  94.       - gateway  
  95.     - name: floating  
  96.       static_ips:  
  97.       - 10.68.19.133  
  98.     properties:  
  99.       db: databases  
  100.   
  101.   - name: dea  
  102.     release: cf-release  
  103.     template:  
  104.       - dea_next  
  105.     instances: 1  
  106.     resource_pool: small  
  107.     networks:  
  108.       - name: default  
  109.         default: [dns, gateway]  
  110.   
  111. properties:  
  112.   cf:  
  113.     name: cf  
  114.     dns: vsc.com  
  115.     ip_addresses: ["10.68.19.133"]  
  116.     deployment_size: medium  
  117.     security_group: default  
  118.     persistent_disk: 4096  
  119.     common_password: c1oudc0w  
  120.     dea_server_ram: 4096  
  121.   
  122.   domain: vsc.com  
  123.   system_domain: vsc.com.com  
  124.   system_domain_organization: system_domain  
  125.   app_domains:  
  126.     - vsc.com  
  127.   
  128.   networks:  
  129.     apps: default  
  130.     management: default  
  131.   
  132.   nats:  
  133.     address: 0.core.default.cf.bosh  
  134.     machines:  
  135.     - 0.core.default.cf.bosh  
  136.     port: 4222  
  137.     user: nats  
  138.     password: c1oudc0w  
  139.     authorization_timeout: 5  
  140.   
  141.   router:  
  142.     address: 0.api.default.cf.bosh  
  143.     port: 8081  
  144.     status:  
  145.       port: 8080  
  146.       user: gorouter  
  147.       password: c1oudc0w  
  148.   
  149.   dea: &dea  
  150.     memory_mb: 4096  
  151.     disk_mb: 10240  
  152.     directory_server_protocol: http  
  153.   
  154.   dea_next: *dea  
  155.   
  156.   syslog_aggregator:  
  157.     address: 0.core.default.cf.bosh  
  158.     port: 54321  
  159.   
  160.   nfs_server:  
  161.     address: 0.data.default.cf.bosh  
  162.     network: "*.cf.bosh"  
  163.     idmapd_domain: vsc.com  
  164.   
  165.   debian_nfs_server:  
  166.     no_root_squash: true  
  167.   
  168.   databases: &databases  
  169.     db_scheme: postgres  
  170.     address: 0.data.default.cf.bosh  
  171.     port: 5524  
  172.     roles:  
  173.       - tag: admin  
  174.         name: ccadmin  
  175.         password: c1oudc0w  
  176.       - tag: admin  
  177.         name: uaaadmin  
  178.         password: c1oudc0w  
  179.     databases:  
  180.       - tag: cc  
  181.         name: ccdb  
  182.         citext: true  
  183.       - tag: uaa  
  184.         name: uaadb  
  185.         citext: true  
  186.   
  187.   ccdb: &ccdb  
  188.     db_scheme: postgres  
  189.     address: 0.data.default.cf.bosh  
  190.     port: 5524  
  191.     roles:  
  192.       - tag: admin  
  193.         name: ccadmin  
  194.         password: c1oudc0w  
  195.     databases:  
  196.       - tag: cc  
  197.         name: ccdb  
  198.         citext: true  
  199.   
  200.   ccdb_ng: *ccdb  
  201.   
  202.   uaadb:   
  203.     db_scheme: postgresql  
  204.     address: 0.data.default.cf.bosh  
  205.     port: 5524  
  206.     roles:  
  207.       - tag: admin  
  208.         name: uaaadmin  
  209.         password: c1oudc0w  
  210.     databases:  
  211.       - tag: uaa  
  212.         name: uaadb  
  213.         citext: true  
  214.   
  215.   cc_api_version: v2  
  216.   
  217.   cc: &cc  
  218.     logging_level: debug  
  219.     external_host: api  
  220.     srv_api_uri: http://api.vsc.com  
  221.     cc_partition: default  
  222.     db_encryption_key: c1oudc0w  
  223.     bootstrap_admin_email: [email protected]  
  224.     bulk_api_password: c1oudc0w  
  225.     uaa_resource_id: cloud_controller  
  226.     staging_upload_user: uploaduser  
  227.     staging_upload_password: c1oudc0w  
  228.     resource_pool:  
  229.       resource_directory_key: cc-resources  
  230.       # Local provider when using NFS  
  231.       fog_connection:  
  232.         provider: Local  
  233.     packages:  
  234.       app_package_directory_key: cc-packages  
  235.     droplets:  
  236.       droplet_directory_key: cc-droplets  
  237.     default_quota_definition: runaway  
  238.   
  239.   ccng: *cc  
  240.   
  241.   login:  
  242.     enabled: false  
  243.   
  244.   uaa:  
  245.     url: http://uaa.vsc.com  
  246.     spring_profiles: postgresql  
  247.     no_ssl: true  
  248.     catalina_opts: -Xmx768m -XX:MaxPermSize=256m  
  249.     resource_id: account_manager  
  250.     jwt:  
  251.       signing_key: |  
  252.         -----BEGIN RSA PRIVATE KEY-----  
  253.         MIICXAIBAAKBgQDHFr+KICms+tuT1OXJwhCUmR2dKVy7psa8xzElSyzqx7oJyfJ1  
  254.         JZyOzToj9T5SfTIq396agbHJWVfYphNahvZ/7uMXqHxf+ZH9BL1gk9Y6kCnbM5R6  
  255.         0gfwjyW1/dQPjOzn9N394zd2FJoFHwdq9Qs0wBugspULZVNRxq7veq/fzwIDAQAB  
  256.         AoGBAJ8dRTQFhIllbHx4GLbpTQsWXJ6w4hZvskJKCLM/o8R4n+0W45pQ1xEiYKdA  
  257.         Z/DRcnjltylRImBD8XuLL8iYOQSZXNMb1h3g5/UGbUXLmCgQLOUUlnYt34QOQm+0  
  258.         KvUqfMSFBbKMsYBAoQmNdTHBaz3dZa8ON9hh/f5TT8u0OWNRAkEA5opzsIXv+52J  
  259.         duc1VGyX3SwlxiE2dStW8wZqGiuLH142n6MKnkLU4ctNLiclw6BZePXFZYIK+AkE  
  260.         xQ+k16je5QJBAN0TIKMPWIbbHVr5rkdUqOyezlFFWYOwnMmw/BKa1d3zp54VP/P8  
  261.         +5aQ2d4sMoKEOfdWH7UqMe3FszfYFvSu5KMCQFMYeFaaEEP7Jn8rGzfQ5HQd44ek  
  262.         lQJqmq6CE2BXbY/i34FuvPcKU70HEEygY6Y9d8J3o6zQ0K9SYNu+pcXt4lkCQA3h  
  263.         jJQQe5uEGJTExqed7jllQ0khFJzLMx0K6tj0NeeIzAaGCQz13oo2sCdeGRHO4aDh  
  264.         HH6Qlq/6UOV5wP8+GAcCQFgRCcB+hrje8hfEEefHcFpyKH+5g1Eu1k0mLrxK2zd+  
  265.         4SlotYRHgPCEubokb2S1zfZDWIXW3HmggnGgM949TlY=  
  266.         -----END RSA PRIVATE KEY-----  
  267.       verification_key: |  
  268.         -----BEGIN PUBLIC KEY-----  
  269.         MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDHFr+KICms+tuT1OXJwhCUmR2d  
  270.         KVy7psa8xzElSyzqx7oJyfJ1JZyOzToj9T5SfTIq396agbHJWVfYphNahvZ/7uMX  
  271.         qHxf+ZH9BL1gk9Y6kCnbM5R60gfwjyW1/dQPjOzn9N394zd2FJoFHwdq9Qs0wBug  
  272.         spULZVNRxq7veq/fzwIDAQAB  
  273.         -----END PUBLIC KEY-----  
  274.     cc:  
  275.       client_secret: c1oudc0w  
  276.     admin:  
  277.       client_secret: c1oudc0w  
  278.     batch:  
  279.       username: batchuser  
  280.       password: c1oudc0w  
  281.     client:  
  282.       autoapprove:  
  283.         - cf  
  284.     clients:  
  285.       cf:  
  286.         override: true  
  287.         authorized-grant-types: password,implicit,refresh_token  
  288.         authorities: uaa.none  
  289.         scope: cloud_controller.read,cloud_controller.write,openid,password.write,cloud_controller.admin,scim.read,scim.write  
  290.         access-token-validity: 7200  
  291.         refresh-token-validity: 1209600  
  292.     scim:  
  293.       users:  
  294.       - admin|c1oudc0w|scim.write,scim.read,openid,cloud_controller.admin  
  295.       - services|c1oudc0w|scim.write,scim.read,openid,cloud_controller.admin  

修改cf.yml文件

director_uuid:修改为Bosh Director的UUID,可以通过bosh status查看;

releases的name属性,修改为之前创建CloudFoundry的Release包时输入的包名;

10.58.19.133:修改为可用的Floating IP;

vsc.com:域名,CF平台不能通过IP直接访问使用,必须配置域名,可以自己任意写个域名,然后配置本地DNS Server进行解析即可;

反馈:

[plain]  view plain copy
  1. root@bosh-cli:~/bosh-workspace/deployments# bosh deployment cf-149.yml  

[plain]  view plain copy
  1. root@bosh-cli:~/bosh-workspace/deployments# bosh deploy  
  2. Getting deployment properties from director...  
  3. Unable to get properties list from director, trying without it...  
  4. Compiling deployment manifest...  
  5. Cannot get current deployment information from director, possibly a new deployment  
  6. Please review all changes carefully  
  7. Deploying `cf-149.yml' to `bosh' (type 'yes' to continue): yes  
  8.   
  9. Director task 10  
  10.   
  11. Preparing deployment  
  12.   binding deployment (00:00:00)  
  13.   binding releases (00:00:00)  
  14.   binding existing deployment (00:00:00)  
  15.   binding resource pools (00:00:00)  
  16.   binding stemcells (00:00:00)  
  17.   binding templates (00:00:01)  
  18.   binding properties (00:00:00)  
  19.   binding unallocated VMs (00:00:00)  
  20.   binding instance networks (00:00:00)  
  21. Done                    9/9 00:00:01  
  22.   
  23. Preparing package compilation  
  24.   
  25. Preparing DNS  
  26.   binding DNS (00:00:00)  
  27. Done                    1/1 00:00:00  
  28.   
  29. Creating bound missing VMs  
  30.   small/0 (00:00:42)  
  31.   small/1 (00:00:57)  
  32.   small/2 (00:01:02)  
  33.   small/3 (00:01:10)  
  34. Done                    4/4 00:01:10  
  35.   
  36. Binding instance VMs  
  37.   data/0 (00:00:01)  
  38.   dea/0 (00:00:01)  
  39.   core/0 (00:00:01)  
  40.   api/0 (00:00:01)  
  41. Done                    4/4 00:00:01  
  42.   
  43. Preparing configuration  
  44.   binding configuration (00:00:02)  
  45. Done                    1/1 00:00:02  
  46.   
  47. Updating job data  
  48.   data/0 (canary) (00:00:53)  
  49. Done                    1/1 00:00:53  
  50.   
  51. Updating job core  
  52.   core/0 (canary) (00:01:08)  
  53. Done                    1/1 00:01:08  
  54.   
  55. Updating job api  
  56.   api/0 (canary) (00:01:04)  
  57. Done                    1/1 00:01:04  
  58.   
  59. Updating job dea  
  60.   dea/0 (canary) (00:03:20)  
  61. Done                    1/1 00:03:20  
  62.   
  63. Task 10 done  
  64. Started         2013-12-18 11:20:53 UTC  
  65. Finished        2013-12-18 11:29:37 UTC  
  66. Duration        00:08:44  
  67.   
  68. Deployed `cf-149.yml' to `bosh'  
部署过程可能会因为OpenStack的VM虚拟机创建时间过长或PING虚拟机响应过长导致失败,只需要删除Deployments后再重新部署即可。

Deployment删除命令:

[plain]  view plain copy
  1. root@bosh-cli:~/bosh-workspace/deployments# bosh delete deployment cf  
部署成功之后可以使用命令查看虚拟机运行状态:

[plain]  view plain copy
  1. root@bosh-cli:~/bosh-workspace/deployments# bosh vms  
  2. Deployment `cf'  
  3.   
  4. Director task 191  
  5.   
  6. Task 191 done  
  7.   
  8. +-----------+---------+---------------+--------------------------+  
  9. | Job/index | State   | Resource Pool | IPs                      |  
  10. +-----------+---------+---------------+--------------------------+  
  11. | api/0     | running | small         | 50.50.0.16, 10.68.19.133 |  
  12. | core/0    | running | small         | 50.50.0.17               |  
  13. | data/0    | running | small         | 50.50.0.14               |  
  14. | dea/0     | running | small         | 50.50.0.15               |  
  15. +-----------+---------+---------------+--------------------------+  
  16.   
  17. VMs total: 4  

全部Job为Running状态则正常。

6、使用CF客户端管理CloudFoundry运行环境

注意:请先配置DNS Server,对设置的虚拟域名(vsc.com)进行解析,参照文章:《配置DNS Server》和《配置OpenStack环境DNS》

6.1、安装CF命令行工具

[plain]  view plain copy
  1. gem install cf  

6.2、切换CF指向为api.vsc.com

[plain]  view plain copy
  1. root@bosh-cli:~# cf target api.vsc.com  
  2. Setting target to http://api.vsc.com... OK  
  3.   
  4. target: http://api.vsc.com  
  5. organization: system_domain  
6.3、登陆到CF平台,本环境账号密码为admin/c1oudc0w

[plain]  view plain copy
  1. root@bosh-cli:~# cf login admin  
  2. target: http://api.vsc.com  
  3.   
  4. Password> ********  
  5.   
  6. Authenticating... OK  
  7. There are no spaces. You may want to create one with create-space.  
6.4、创建组织
[plain]  view plain copy
  1. root@bosh-cli:~# cf create-org venusource  
  2. Creating organization venusource... OK  
  3. Switching to organization venusource... OK  
  4. There are no spaces. You may want to create one with create-space.  
6.5、创建并切换空间
[plain]  view plain copy
  1. root@bosh-cli:~# cf create-space development  
  2. Creating space development... OK  
  3. Adding you as a manager... OK  
  4. Adding you as a developer... OK  
  5. Space created! Use `cf switch-space development` to target it.  
  6. root@bosh-cli:~# cf switch-space development  
  7. Switching to space development... OK  
  8.   
  9. target: http://api.vsc.com  
  10. organization: venusource  
  11. space: development  
6.6、下载测试Ruby工程
[plain]  view plain copy
  1. root@bosh-cli:~# git clone https://github.com/cloudfoundry-community/cf_demoapp_ruby_rack.git  
6.7、打包并发布测试工程
[plain]  view plain copy
  1. root@bosh-cli:~# cd cf_demoapp_ruby_rack/  
  2. root@bosh-cli:~/cf_demoapp_ruby_rack# rm manifest.yml  
  3. root@bosh-cli:~/cf_demoapp_ruby_rack# bundle  
  4. Resolving dependencies...  
  5. Using rack (1.5.2)  
  6. Using bundler (1.3.5)  
  7. Your bundle is complete!  
  8. Use `bundle show [gemname]` to see where a bundled gem is installed.  
  9. root@bosh-cli:~/cf_demoapp_ruby_rack# cf push  
  10. Name> hello  
  11.   
  12. Instances> 1  
  13.   
  14. 1: 128M  
  15. 2: 256M  
  16. 3: 512M  
  17. 4: 1G  
  18. Memory Limit> 1  
  19.   
  20. Creating hello... OK  
  21.   
  22. 1: hello  
  23. 2: none  
  24. Subdomain> hello  
  25.   
  26. 1: vsc.com  
  27. 2: none  
  28. Domain> mycloud.com  
  29.   
  30. Creating route hello.mycloud.com... OK  
  31. Binding hello.mycloud.com to hello... OK  
  32.   
  33. Create services for application?> n  
  34.   
  35. Save configuration?> n  
  36.   
  37. Uploading hello... OK  
  38. Starting hello... OK  
  39. -----> Downloaded app package (4.0K)  
  40.   
  41. ....  
  42.   
  43. Checking hello...  
  44. Staging in progress...  
  45.   0/1 instances: 1 starting  
  46.   0/1 instances: 1 starting  
  47.   0/1 instances: 1 starting  
  48.   1/1 instances: 1 running  
  49. OK  

部署完毕!欢迎各位交流指正,谢谢!

你可能感兴趣的:(CloudFoundry)