近期Docker实在很火,介于本菜接触cf和docker也有一段时间了,但是很多同学一看到cf的第三代运行时迟迟不发布,框架过于繁重,都转去研究marathon和k8s了,其实现在版本的Diego大体上已经可用,部署只是入门也相对简单,希望更多的童鞋能往更深的代码设计和二次开发上发展。

windows环境:

1.准备vagrant+virtualBox
这个就不用说了,直接从官网下载
virtualBox : http://download.virtualbox.org/virtualbox/5.0.2/VirtualBox-5.0.2-102096-Win.exe
vagrant : 这个官网下载最新的即可。

2.准备最新的bosh-lite-warden-box
bosh-lite-virtualbox-ubuntu-trusty-9000.45.0.box
https://d2u2rxhdayhid5.cloudfront.net/bosh-lite-virtualbox-ubuntu-trusty-9000.45.0.box
在某盘下新建目录,并将这个box文件放入

3.启动box
在某盘新建vagrant目录,或者一个好记的名字,新建Vagrantfile文件,将以下内容写入:

###
VM_MEMORY = ENV.fetch("VM_MEMORY", 4*1024).to_i
VM_CORES = ENV.fetch("VM_CORES", 4).to_i

Vagrant.configure('2') do |config|

  config.vm.hostname='bosh-lite'
  config.vm.box = "boshlite-ubuntu-trusty-build-diego"
  config.vm.network :private_network, ip: '192.168.59.4'

  config.vm.provider :virtualbox do |v, override|
    override.vm.box_url = "file:///d:/temp/bosh-lite-virtualbox-ubuntu-trusty-9000.45.0.box"
    v.customize ["modifyvm", :id, "--memory", VM_MEMORY]
    v.customize ["modifyvm", :id, "--cpus", VM_CORES]
  end

end
###

启动:cmd进入到你的vagrant目录,vagrant up 执行启动命令。
启动后ssh登录 默认127.0.0.1:2222 user:vagrant passwd:vagrant

4.安装必要软件:
sudo apt-get update
sudo apt-get install vim curl 
下载spiff,将二进制文件放入到/usr/sbin

5.上传最新的warden stemcell
下载后放到你的vagrant目录下(windows下的,就是你的vagrantfile的目录,此目录是共享的):
#bosh target  192.168.59.4:25555
admin/admin
#bosh upload stemcell /vagrant/latest-bosh-stemcell-warden.tgz

6.制作cf-release v215版本
在当前目录下:/home/vagrant/workspace
cd cf-release
./update
git checkout v215
bosh create release releases/cf-215.yml
bosh upload release releases/cf-215.tgz

PS:假如在制作tar包觉得中断总让你不爽,给个脚本:/home/vagrant/monit.sh 进入无人值守
#!/bin/bash

pushd /home/vagrant/workspace/diego-release
    bosh create release releases/cf-215.yml || /home/vagrant/monit.sh
popd

7.制作diego-garden-linux release 0.303.0版本
在当前目录下:/home/vagrant/workspace
cd garden-linux-release
bundle install (这里会有个问题,如果rubygems.org无法通,则可将Gemfile和Gemfile.lock里的source替换一下,不过install完成以后,请按原样替换回去。)
git submodule update --init
git checkout v0.303.0
bosh -n upload release releases/garden-linux/garden-linux-0.303.0.yml

8.制作diego-release 0.1427.0版本
在当前目录下:/home/vagrant/workspace
cd diego-release
git submodule update --init
git checkout 0.1427.0
bosh create release releases/diego-0.1427.0.yml
bosh upload release /home/vagrant/workspace/diego-release/releases/diego-0.1427.0.tgz

PS:一样会出现网络中断的问题
#!/bin/bash

pushd /home/vagrant/workspace/diego-release
    bosh create release releases/diego-0.1427.0.yml || /home/vagrant/monit.sh
popd

#bosh releases 查看所有的releases

9.准备bosh-lite
在当前目录:/home/vagrant/
#git clone https://github.com/pivotalservices/bosh-lite-install
#mkdir /home/vagrant/deployments
#cd bosh-lite-install
#./scripts/print-director-stub > ~/deployments/director.yml

10.制作cf-release diego版的部署文件,并部署
在当前目录下: /home/vagrant/bosh-lite-install
#./generate_deployment_manifest warden ~/deployments/director.yml   /home/vagrant/workspace/diego-release/stubs-for-cf-release/enable_consul_with_cf.yml   /home/vagrant/workspace/diego-release/stubs-for-cf-release/enable_diego_windows_in_cc.yml   /home/vagrant/workspace/diego-release/stubs-for-cf-release/enable_diego_ssh_in_cc.yml   /home/vagrant/workspace/diego-release/manifest-generation/bosh-lite-stubs/property-overrides.yml > ~/deployments/cf.yml
#bosh deployment ~/deployments/cf.yml
#bosh deploy

11.制作diego-release部署文件,并部署
在当前目录下: /home/vagrant/bosh-lite-install
#./generate-deployment-manifest ~/director.yml ~/diego-release/manifest-generation/bosh-lite-stubs/property-overrides.yml ~/diego-release/manifest-generation/bosh-lite-stubs/instance-count-overrides.yml ~/diego-release/manifest-generation/bosh-lite-stubs/persistent-disk-overrides.yml ~/diego-release/manifest-generation/bosh-lite-stubs/iaas-settings.yml ~/diego-release/manifest-generation/bosh-lite-stubs/additional-jobs.yml ~/deployments/ > ~/deployments/diego.yml
#bosh deployment ~/deployments/diego.yml
#bosh deploy

12.查看部署情况
#bosh vms 

13.配置cf 工具
1).开启diego_docker模式
#cf enable-feature-flag diego_docker
2).安装diego插件
#cf install-plugin Diego-Beta -r CF-Community
3).docker-push一下?
#cf docker-push helloDocker tutum/tomcat:8.0
4).如果是失败,没关系,等一会,他只是在从docker官网上下载会慢一些

14.windows下绑定路由
route add 10.244.0.0/19 192.168.59.4




Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐