如何使用Bosh部署应用程序(一)
更新时间:2018年04月23日
安装bosh环境
下载Bosh二进制安装程序
点击下载
安装virtulbox
wget https://download.virtualbox.org/virtualbox/5.2.10/virtualbox-5.2_5.2.10-122088~Ubuntu~trusty_amd64.deb
dpkg -i virtualbox-5.2_5.2.10-122088~Ubuntu~trusty_amd64.deb
安装一些依赖程序包
sudo apt-get install -y build-essential zlibc zlib1g-dev ruby ruby-dev openssl libxslt-dev libxml2-dev libssl-dev libreadline6 libreadline6-dev libyaml-dev libsqlite3-dev sqlite3
推荐使用bosh-deployment来引导Director
$ git clone https://github.com/cloudfoundry/bosh-deployment ~/workspace/bosh-deployment
$ mkdir -p ~/deployments/vbox
$ cd ~/deployments/vbox
$ bosh create-env ~/workspace/bosh-deployment/bosh.yml --state ./state.json -o ~/workspace/bosh-deployment/virtualbox/cpi.yml -o ~/workspace/bosh-deployment/virtualbox/outbound-network.yml -o ~/workspace/bosh-deployment/bosh-lite.yml -o ~/workspace/bosh-deployment/bosh-lite-runc.yml -o ~/workspace/bosh-deployment/jumpbox-user.yml --vars-store ./creds.yml -v director_name="bosh-lite" -v internal_ip=192.168.50.6 -v internal_gw=192.168.50.1 -v internal_cidr=192.168.50.0/24 -v outbound_network_name=NatNetwork
配置环境
$ bosh alias-env vbox -e 192.168.50.6 --ca-cert <(bosh int ./creds.yml --path /director_ssl/ca)
$ export BOSH_CLIENT=admin
$ export BOSH_CLIENT_SECRET=`bosh int ./creds.yml --path /admin_password`
check env
$ bosh -e vbox env
Using environment ‘192.168.50.6‘ as ‘?‘
Name: ...
User: admin
Succeeded
add route
sudo route add -net 10.244.0.0/16 gw 192.168.50.6
进入软件的部署环节
部署资源需求配置
- 不管部署什么应用,前提必须要有cloud config,在部署应用或者服务时,可以根据具体的场景更新cloud config中虚拟机规格的配置更新
- 一但cloud config被更新,之前的将被视为过期,Director会在下次进行
bosh deploy
时应用这些配置 - 每个应用gitrepo中一般都会定义cloud config的配置,我们可以通过一下方式更新
$ bosh -e vbox update-cloud-config /PATH/TO/cloud-config.yml
- 对于不同类型的CPI,有不同的配置属性
上传基础操作系统镜像Stemcell
- 部署应用就要提前准备好应用要运行的操作系统,window/centos/ubuntu等,一般会在部署的应用文档中有介绍
- 建议提前下载好需要的Stemcell,网络传输可能会导致失败,另外版本的更新非常快,要注意自己使用的版本
这是一个栗子:
bosh -e vbox upload-stemcell https://bosh.io/d/stemcells/bosh-warden-boshlite-ubuntu-trusty-go_agent?v=3468.17 --sha1 1dad6d85d6e132810439daba7ca05694cec208ab
验证性测试
git clone https://github.com/concourse/concourse-bosh-deployment.git
bosh -e $BOSH_ENVIRONMENT deploy -d concourse concourse.yml -l ../versions.yml --vars-store cluster-creds.yml -o operations/static-web.yml -o operations/no-auth.yml --var web_ip=10.244.15.2 --var external_url=http://10.244.15.2:8080 --var network_name=concourse --var web_vm_type=concourse --var db_vm_type=concourse --var db_persistent_disk_type=db --var worker_vm_type=concourse --var deployment_name=concourse
fly -t ci login -c http://10.244.15.2:8080
原文地址:http://blog.51cto.com/bkmaster/2327785
时间: 2024-10-11 01:00:21