bosh-lite 部署cloudfoundry

1. 安装bosh-lite

bosh-lite

1.1 安装bosh命令行

1.1.1 安装ruby

rvm管理工具

1
$ gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
1
$ \curl -sSL https://get.rvm.io | bash -s stable
1
2
$ rvm install 2.3.0
$ rvm use 2.3.0 default

1.1.2 安装bosh_cli命令工具

1
$ gem install bosh_cli --no-ri --no-rdoc

1.2 安装vagrant

vagrant

1
2
$ vagrant --version
Vagrant 1.7.4

1.3 安装VBox

VBox

1
2
$ VBoxManage --version
5.0.16r...

1.4 下载bosh-lite代码

1
2
$ cd ~/workspace
$ git clone https://github.com/cloudfoundry/bosh-lite

1.5 启动vagrant

  • 修改Vagrantfile,增加一行,为了规避vagant的bug
1
config.ssh.insert_key = false
  • 启动
1
$ vagrant up --provider=virtualbox
  • 暂停
1
$ vagrant suspend
  • 添加指向vagrant的路由
  • ==重启机器需要重新执行这一步==
1
$ bin/add-route

2. 使用bosh-lite部署cloudfoundry

  • 生成部署清单
1
2
$ cd cf-release
$ ./scripts/generate-bosh-lite-dev-manifest
  • 上传stemcell
1
$ bosh upload  stemcell ~/cloudfoundry/bosh/bosh-warden-boshlite-ubuntu-trusty-go_agent.tgz
  • 上传cloudfoundry发布包
1
$ bosh upload  release ~/cloudfoundry/bosh/cf-release.tgz
  • 执行部署命令
1
$ bosh deploy

  • 下面的是编译部署的命令
1
2
3
4
$ cd cf-release
$ bosh create release
$ bosh upload release
$ bosh deploy
  • 删除部署
1
$ bosh delete deployment cf-warden
  • 登录到部署好的cloudfoundry环境
1
$ cf login -a https://api.bosh-lite.com --skip-ssl-validation -u admin -p admin
  • 创建组织
1
$ cf create-org realtech
  • 指定组织
1
$ cf target -o realtech
  • 创建空间
1
$ cf create-space admin

3. 使用bosh-lite部署mysql

  • 生成部署清单
1
2
$ cd cf-mysql-release
$ ./scripts/generate-bosh-lite-manifest
  • 上传mysql-release
1
$ bosh upload  release ~/cloudfoundry/bosh/cf-mysql-release.tgz
  • 部署mysql
1
$ bosh deploy
  • cf 创建mysql服务
1
bosh run errand broker-registrar
  • 或者是执行以下的命令
1
$ cf create-service-broker p-mysql admin password https://p-mysql.bosh-lite.com:443

https://github.com/cloudfoundry-samples/spring-music

4. 使用bosh-lite部署redis

  • 生成部署清单
1
2
$ cd cf-redis-release
$ ./scripts/generate-deployment-manifest warden templates/sample_stubs/infrastructure-warden.yml - cf-redis-lite.yml
  • 上传redis-release
1
2
$ bosh upload  release ~/cloudfoundry/bosh/cf-routing-release-0.137.0.tgz
$ bosh upload release ~/cloudfoundry/bosh/cf-redis-release-426.0.0.tgz
1
aria2c --split=10 -c -j 10 http://bosh.io/d/github.com/pivotal-cf/cf-redis-release
  • cf 创建redis服务
1
$ cf create-service-broker redis admin admin https://redis-broker.bosh-lite.com:443