CloudFoundry in 1 Box之Lattice使用介绍
本文在介绍关于CloudFoundry in 1 Box的基础上,重点探讨了Lattice的使用具体步骤,步骤简单易上手操作,文章内容步步紧凑,希望大家根据这篇文章可以有所收获。
1. Lattice简介
Lattice是一个很有意思的项目,设计目标是为Cloud Foundry的开发人员提供一个最小的App运行时环境,所以它只选择了Cloud Foundry中与App运行相关的组件,从而组成了一个最简化的开发测试Cloud Foundry App的环境。
如上图所示,Lattice仅包含如下组件
Router:负责访问App请求的routing
Diego:Cloud Foundry App的运行时环境
Blob store: App staging的存储空间
loggregator:log服务器,供app开发者查看app运行时日志
下面我们就来一步一步搭建一个Lattice环境
2. 环境准备
笔者采用的事Cent OS 7.2作为宿主机的操作系统,VirtualBox为虚拟机平台
2.1 安装以来的软件包
#rpm-Uvhhttp://mirror.pnl.gov/epel/7/x86_64/e/epel-release-7-5.noarch.rpm#yuminstall-yvimgitscreenkernel*libX11qtSDLSDL-devellibxml2-devel\libvpxlibpnglibXtlibXmulibxsltlibxslt-developenssl\openssl-devellibXcursorlibXineramaqtqt-develwgetgccunzipntpdatenet-tools
2.2 安装Ruby环境
笔者使用rbenv来安装和管理ruby
#gitclonegit://github.com/sstephenson/rbenv.git$HOME/.rbenv#gitclonehttps://github.com/sstephenson/ruby-build.git$HOME/.rbenv/plugins/ruby-build#echo'exportPATH="$HOME/.rbenv/bin:$PATH"'>>~/.bash_profile#echo'eval"$(rbenvinit-)"'>>~/.bash_profile#source~/.bash_profile#rbenvinstall2.3.0#rbenvglobal2.1.3#geminstallbundle#geminstallnokogiri—--use-system-libraries
2.3安装Vagrant
#wgethttps://releases.hashicorp.com/vagrant/1.8.1/vagrant_1.8.1_x86_64.rpm#rpm-Uvhvagrant_1.8.1_x86_64.rpm
验证vagrant
#vagrant--versionVagrant1.8.1
2.4 安装VirtualBox
#wgethttp://download.virtualbox.org/virtualbox/5.0.16/VirtualBox-5.0-5.0.16_105871_el7-1.x86_64.rpm##安装virtualbox时需要linuxkernel的源代码,设置KERN_DIR环境变量指示kernel源代码路径#exportKERN_DIR=/usr/src/kernels/<yourkerneldir>#rpm-UvhVirtualBox-5.0-5.0.16_105871_el7-1.x86_64.rpm
验证virtualbox是否安装成功
#VBoxManage--version5.0.16r105871
3. 部署Lattice
3.1 从github上下载最新的lattice release
#wgethttps://github.com/cloudfoundry-incubator/lattice-release/releases/latest
3.2 解压Lattice
#gunziplattice-bundle-<version>.zip
3.3 启动Lattice
#cd<lattice>/vagrant#vagrantup--provider=virtualbox
3.4 查看PCF-dev component
#cd<lattice>/vagrant#vagrantssh##登陆pcf-dev虚拟机#登陆之后的pcf-dev虚拟机$sudo-i#monitsummaryroot@agent-id-pcfdev-0:~#monitsummaryTheMonitdaemon5.2.4uptime:17mProcess'auctioneer'runningProcess'receptor'runningProcess'bbs'runningProcess'converger'runningProcess'file_server'runningProcess'route_emitter'runningProcess'ssh_proxy'runningProcess'rep'runningProcess'rootfses'runningProcess'garden'runningFile'haproxy_config'accessibleProcess'haproxy'runningProcess'router_configurer'runningProcess'tcp_emitter'runningProcess'routing-api'runningProcess'consul_agent'runningProcess'doppler'runningProcess'gorouter'runningProcess'loggregator_trafficcontroller'runningProcess'metron_agent'runningProcess'nats'runningProcess'route_registrar'runningProcess'etcd'runningSystem'system_lattice-colocated-0'running
启动后的Lattice虚拟机配置了两块网卡,一块用来连接CloudFoundry网络,使用10.0.2.15/24;一块用来和宿主机通信,使用IP 192.168.11.11. Lattice默认的域名为local.lattice.cf
如果设有http/https proxy,需要执行如下步骤
exportno_proxy=192.168.11.11,local.lattice.cf
至此,Lattice环境准备完毕。
4. 部署app到Lattice
4.1 安装Lattice CLI
#curl-Ohttp://receptor.local.lattice.cf/v1/sync/linux/ltc#chmod+xltc
4.2 Lattice target
Lattice默认的域名为local.lattice.cf, *.local.lattice.cf会被解析到192.168.11.11
#pingxyz.local.lattice.cfPINGxyz.local.pcfdev.io(192.168.11.11)56(84)bytesofdata.64bytesfrom192.168.11.11:icmp_seq=1ttl=64time=0.818ms64bytesfrom192.168.11.11:icmp_seq=2ttl=64time=1.45ms64bytesfrom192.168.11.11:icmp_seq=3ttl=64time=1.33ms64bytesfrom192.168.11.11:icmp_seq=4ttl=64time=1.69ms64bytesfrom192.168.11.11:icmp_seq=5ttl=64time=1.25ms^C---xyz.local.pcfdev.iopingstatistics---5packetstransmitted,5received,0%packetloss,time4006msrttmin/avg/max/mdev=0.818/1.311/1.696/0.292ms
#latticetargetlocal.pcfdev.ioAPIlocationset.
4.3 部署App
因为lattice环境仅包含运行Cloud Foundry App的最小环境,不包含任何buildpack,所以使用Lattice运行Cloud Foundry App需要两个步骤
build Cloud Foundry droplet,在这个步骤中,需要显示指定buildpack,以ruby app为例
#ltcbuild-droplethellorubyhttps://github.com/cloudfoundry/ruby-buildpackUploadingapplicationbits...Uploaded.Submittedbuildofhelloruby04/2022:30:00.57[BUILD|0]Successfullycreatedcontainer04/2022:30:06.20[DROPLET|0]Deletedhttp://local.lattice.cf:8444/blobs/helloruby-bits.zip.04/2022:30:06.22[DROPLET|0]Exitstatus004/2022:30:06.39[BUILD|0]Exitstatus004/2022:30:27.50[BUILD|0]------->Buildpackversion1.6.1604/2022:30:27.68[BUILD|0]Downloaded[https://pivotal-buildpacks.s3.amazonaws.com/ruby/binaries/shared/bundler-1.11.2.tgz]04/2022:30:31.68[BUILD|0]----->CompilingRuby/Rack04/2022:30:32.38[BUILD|0]Downloaded[https://pivotal-buildpacks.s3.amazonaws.com/concourse-binaries/ruby/ruby-2.3.0-linux-x64.tgz]04/2022:31:07.03[BUILD|0]----->UsingRubyversion:ruby-2.3.004/2022:31:07.48[BUILD|0]######WARNING:04/2022:31:07.48[BUILD|0]removethe`.bundle/`folderfromyourrepoandaddittoyour`.gitignore`file.04/2022:31:07.48[BUILD|0]Youhavethe`.bundle/config`filecheckedintoyourrepository04/2022:31:07.48[BUILD|0]https://devcenter.heroku.com/articles/bundler-configuration04/2022:31:07.48[BUILD|0]Itcontainslocalstatelikethelocationoftheinstalledbundle04/2022:31:07.48[BUILD|0]aswellasconfiguredgitlocalgems,andothersettingsthatshould04/2022:31:07.48[BUILD|0]----->Installingdependenciesusingbundler1.11.204/2022:31:07.48[BUILD|0]notbesharedbetweenmultiplecheckoutsofasinglerepo.Please04/2022:31:08.27[BUILD|0]Downloaded[https://pivotal-buildpacks.s3.amazonaws.com/ruby/binaries/cflinuxfs2/libyaml-0.1.6.tgz]04/2022:31:11.03[BUILD|0]Running:bundleinstall--withoutdevelopment:test--pathvendor/bundle--binstubsvendor/bundle/bin-j4--deployment04/2022:31:14.33[BUILD|0]Fetchinggemmetadatafromhttps://ruby.taobao.org/....04/2022:31:14.63[BUILD|0]Fetchingversionmetadatafromhttps://ruby.taobao.org/..04/2022:31:15.49[BUILD|0]Installingkgio2.9.2withnativeextensions04/2022:31:15.63[BUILD|0]Installingrake10.4.204/2022:31:15.82[BUILD|0]Installingrack1.6.004/2022:31:17.23[BUILD|0]Installingraindrops0.13.0withnativeextensions04/2022:31:17.40[BUILD|0]Installingrdiscount2.1.7.1withnativeextensions04/2022:31:54.47[BUILD|0]Installingtilt1.4.104/2022:31:54.77[BUILD|0]Usingbundler1.11.204/2022:31:55.19[BUILD|0]Installingrack-protection1.5.304/2022:31:56.16[BUILD|0]Installingsinatra1.4.504/2022:32:38.00[BUILD|0]Bundlecomplete!7Gemfiledependencies,10gemsnowinstalled.04/2022:32:38.00[BUILD|0]Gemsinthegroupsdevelopmentandtestwerenotinstalled.04/2022:32:38.00[BUILD|0]Bundledgemsareinstalledinto./vendor/bundle.04/2022:32:38.04[BUILD|0]Bundlecompleted(87.00s)04/2022:32:38.06[BUILD|0]Cleaningupthebundlercache.04/2022:32:40.00[BUILD|0]----->Writingconfig/database.ymltoreadfromDATABASE_URL04/2022:32:41.31[BUILD|0]######WARNING:04/2022:32:41.31[BUILD|0]Youhavethe`.bundle/config`filecheckedintoyourrepository04/2022:32:41.31[BUILD|0]Itcontainslocalstatelikethelocationoftheinstalledbundle04/2022:32:41.31[BUILD|0]aswellasconfiguredgitlocalgems,andothersettingsthatshould04/2022:32:41.31[BUILD|0]notbesharedbetweenmultiplecheckoutsofasinglerepo.Please04/2022:32:41.31[BUILD|0]removethe`.bundle/`folderfromyourrepoandaddittoyour`.gitignore`file.04/2022:32:41.31[BUILD|0]https://devcenter.heroku.com/articles/bundler-configuration04/2022:32:58.50[BUILD|0]Exitstatus004/2022:32:59.45[DROPLET|0]Uploaded/tmp/droplettohttp://local.lattice.cf:8444/blobs/helloruby-droplet.tgz.04/2022:32:59.49[DROPLET|0]Exitstatus0#tclist-dropletsDropletCreatedAtSizehelloruby04/2014:32:59.0020.3M
2. 启动droplet
#ltclaunch-droplethellorubyhellorubyNoportspecified.Defaultingto8080.CreatingApp:helloruby.04/2022:37:00.15[APP|0]Creatingcontainer.04/2022:37:01.77[APP|0]Successfullycreatedcontainer..............04/2022:37:16.10[HEALTH|0]healthcheckfailed04/2022:37:16.14[HEALTH|0]Exitstatus104/2022:37:16.56[SSH|0]{"timestamp":"1461163036.562246799","source":"sshd","message":"sshd.started","log_level":1,"data":{}}04/2022:37:16.81[HEALTH|0]healthcheckfailed04/2022:37:16.83[HEALTH|0]Exitstatus1.04/2022:37:17.54[HEALTH|0]healthcheckfailed04/2022:37:17.57[HEALTH|0]Exitstatus1.04/2022:37:18.04[APP|0]I,[2016-04-20T14:37:18.041860#10]INFO--:RefreshingGemlist04/2022:37:18.26[APP|0]I,[2016-04-20T14:37:18.253960#10]INFO--:listeningonaddr=0.0.0.0:8080fd=904/2022:37:18.27[APP|0]I,[2016-04-20T14:37:18.266758#10]INFO--:masterprocessready04/2022:37:18.27[HEALTH|0]healthcheckpassed04/2022:37:18.31[APP|0]I,[2016-04-20T14:37:18.280764#43]INFO--:worker=0ready04/2022:37:18.32[APP|0]I,[2016-04-20T14:37:18.284959#49]INFO--:worker=2ready04/2022:37:18.33[APP|0]I,[2016-04-20T14:37:18.305195#46]INFO--:worker=1ready04/2022:37:18.35[HEALTH|0]Exitstatus0hellorubyisnowrunning.Appisreachableat:http://helloruby.local.lattice.cfhttp://helloruby-8080.local.lattice.cf
上文描述的就是Lattice使用和部署的详细内容,具体使用情况还需要大家自己动手实验使用过才能领会。如果想了解更多相关内容,欢迎关注亿速云行业资讯频道!
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。