CloudFoundry in 1 Box简介:Lattice篇

2023-10-22 15:20

本文主要是介绍CloudFoundry in 1 Box简介:Lattice篇,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

Pivotal Web Service主管工程师 产品经理 吴疆


本篇是《CloudFoundry in 1 Box简介》系列最后一篇,在前面两篇中,我们介绍了Bosh-lite和pcf-dev的架构和部署。在本篇中,我们将详细描述另一个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 -Uvh http://mirror.pnl.gov/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
# yum install -y vim git screen kernel* libX11 qt SDL SDL-devel libxml2-devel \libvpx libpng libXt libXmu libxslt libxslt-devel openssl \ openssl-devel libXcursor libXinerama qt qt-devel wget gcc unzip ntpdate net-tools

2.2 安装Ruby环境

笔者使用rbenv来安装和管理ruby

# git clone git://github.com/sstephenson/rbenv.git $HOME/.rbenv
# git clone https://github.com/sstephenson/ruby-build.git $HOME/.rbenv/plugins/ruby-build 
# echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile 
# echo 'eval "$(rbenv init -)"' >> ~/.bash_profile 
# source ~/.bash_profile 
# rbenv install 2.3.0 
# rbenv global 2.1.3
# gem install bundle
# gem install nokogiri — --use-system-libraries

2.3安装Vagrant

# wget https://releases.hashicorp.com/vagrant/1.8.1/vagrant_1.8.1_x86_64.rpm
# rpm -Uvh vagrant_1.8.1_x86_64.rpm

验证vagrant

# vagrant --version
Vagrant 1.8.1


2.4 安装VirtualBox

# wget http://download.virtualbox.org/virtualbox/5.0.16/VirtualBox-5.0-5.0.16_105871_el7-1.x86_64.rpm
# #安装virtualbox时需要linux kernel的源代码,设置KERN_DIR环境变量指示kernel源代码路径
# export KERN_DIR=/usr/src/kernels/<your kernel dir>
# rpm -Uvh VirtualBox-5.0-5.0.16_105871_el7-1.x86_64.rpm

验证virtualbox是否安装成功

# VBoxManage --version
5.0.16r105871

3. 部署Lattice

3.1 从github上下载最新的lattice release

# wget https://github.com/cloudfoundry-incubator/lattice-release/releases/latest

3.2 解压Lattice

#  gunzip lattice-bundle-<version>.zip


3.3 启动Lattice

# cd <lattice>/vagrant
# vagrant up --provider=virtualbox

3.4 查看PCF-dev component

# cd <lattice>/vagrant
# vagrant ssh ##登陆pcf-dev虚拟机# 登陆之后的pcf-dev虚拟机
$ sudo -i
# monit summary
root@agent-id-pcfdev-0:~# monit summary
The Monit daemon 5.2.4 uptime: 17mProcess 'auctioneer'                running
Process 'receptor'                  running
Process 'bbs'                       running
Process 'converger'                 running
Process 'file_server'               running
Process 'route_emitter'             running
Process 'ssh_proxy'                 running
Process 'rep'                       running
Process 'rootfses'                  running
Process 'garden'                    running
File 'haproxy_config'               accessible
Process 'haproxy'                   running
Process 'router_configurer'         running
Process 'tcp_emitter'               running
Process 'routing-api'               running
Process 'consul_agent'              running
Process 'doppler'                   running
Process 'gorouter'                  running
Process 'loggregator_trafficcontroller' running
Process 'metron_agent'              running
Process 'nats'                      running
Process 'route_registrar'           running
Process 'etcd'                      running
System 'system_lattice-colocated-0' running

启动后的Lattice虚拟机配置了两块网卡,一块用来连接CloudFoundry网络,使用10.0.2.15/24;一块用来和宿主机通信,使用IP 192.168.11.11. Lattice默认的域名为local.lattice.cf

如果设有http/https proxy,需要执行如下步骤

export no_proxy=192.168.11.11,local.lattice.cf

至此,Lattice环境准备完毕。

4. 部署app到Lattice

4.1 安装Lattice CLI

# curl -O http://receptor.local.lattice.cf/v1/sync/linux/ltc
# chmod +x ltc

4.2 Lattice target

Lattice默认的域名为local.lattice.cf, *.local.lattice.cf会被解析到192.168.11.11


# ping xyz.local.lattice.cf
PING xyz.local.pcfdev.io (192.168.11.11) 56(84) bytes of data.
64 bytes from 192.168.11.11: icmp_seq=1 ttl=64 time=0.818 ms
64 bytes from 192.168.11.11: icmp_seq=2 ttl=64 time=1.45 ms
64 bytes from 192.168.11.11: icmp_seq=3 ttl=64 time=1.33 ms
64 bytes from 192.168.11.11: icmp_seq=4 ttl=64 time=1.69 ms
64 bytes from 192.168.11.11: icmp_seq=5 ttl=64 time=1.25 ms
^C
--- xyz.local.pcfdev.io ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4006ms
rtt min/avg/max/mdev = 0.818/1.311/1.696/0.292 ms

# lattice target local.pcfdev.io
API location set.

4.3 部署App


因为lattice环境仅包含运行Cloud Foundry App的最小环境,不包含任何buildpack,所以使用Lattice运行Cloud Foundry App需要两个步骤


1. build Cloud Foundry droplet,在这个步骤中,需要显示指定buildpack,以ruby app为例


# ltc build-droplet helloruby https://github.com/cloudfoundry/ruby-buildpack
Uploading application bits...
Uploaded.
Submitted build of helloruby
04/20 22:30:00.57 [BUILD|0] Successfully created container
04/20 22:30:06.20 [DROPLET|0] Deleted http://local.lattice.cf:8444/blobs/helloruby-bits.zip.
04/20 22:30:06.22 [DROPLET|0] Exit status 0
04/20 22:30:06.39 [BUILD|0] Exit status 0
04/20 22:30:27.50 [BUILD|0] -------> Buildpack version 1.6.16
04/20 22:30:27.68 [BUILD|0]        Downloaded [https://pivotal-buildpacks.s3.amazonaws.com/ruby/binaries/shared/bundler-1.11.2.tgz]
04/20 22:30:31.68 [BUILD|0] -----> Compiling Ruby/Rack
04/20 22:30:32.38 [BUILD|0]        Downloaded [https://pivotal-buildpacks.s3.amazonaws.com/concourse-binaries/ruby/ruby-2.3.0-linux-x64.tgz]
04/20 22:31:07.03 [BUILD|0] -----> Using Ruby version: ruby-2.3.0
04/20 22:31:07.48 [BUILD|0] ###### WARNING:
04/20 22:31:07.48 [BUILD|0]        remove the `.bundle/` folder from your repo and add it to your `.gitignore` file.
04/20 22:31:07.48 [BUILD|0]        You have the `.bundle/config` file checked into your repository
04/20 22:31:07.48 [BUILD|0]        https://devcenter.heroku.com/articles/bundler-configuration
04/20 22:31:07.48 [BUILD|0]        It contains local state like the location of the installed bundle
04/20 22:31:07.48 [BUILD|0]        as well as configured git local gems, and other settings that should
04/20 22:31:07.48 [BUILD|0] -----> Installing dependencies using bundler 1.11.2
04/20 22:31:07.48 [BUILD|0]        not be shared between multiple checkouts of a single repo. Please
04/20 22:31:08.27 [BUILD|0]        Downloaded [https://pivotal-buildpacks.s3.amazonaws.com/ruby/binaries/cflinuxfs2/libyaml-0.1.6.tgz]
04/20 22:31:11.03 [BUILD|0]        Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
04/20 22:31:14.33 [BUILD|0]        Fetching gem metadata from https://ruby.taobao.org/....
04/20 22:31:14.63 [BUILD|0]        Fetching version metadata from https://ruby.taobao.org/..
04/20 22:31:15.49 [BUILD|0]        Installing kgio 2.9.2 with native extensions
04/20 22:31:15.63 [BUILD|0]        Installing rake 10.4.2
04/20 22:31:15.82 [BUILD|0]        Installing rack 1.6.0
04/20 22:31:17.23 [BUILD|0]        Installing raindrops 0.13.0 with native extensions
04/20 22:31:17.40 [BUILD|0]        Installing rdiscount 2.1.7.1 with native extensions
04/20 22:31:54.47 [BUILD|0]        Installing tilt 1.4.1
04/20 22:31:54.77 [BUILD|0]        Using bundler 1.11.2
04/20 22:31:55.19 [BUILD|0]        Installing rack-protection 1.5.3
04/20 22:31:56.16 [BUILD|0]        Installing sinatra 1.4.5
04/20 22:32:38.00 [BUILD|0]        Bundle complete! 7 Gemfile dependencies, 10 gems now installed.
04/20 22:32:38.00 [BUILD|0]        Gems in the groups development and test were not installed.
04/20 22:32:38.00 [BUILD|0]        Bundled gems are installed into ./vendor/bundle.
04/20 22:32:38.04 [BUILD|0]        Bundle completed (87.00s)
04/20 22:32:38.06 [BUILD|0]        Cleaning up the bundler cache.
04/20 22:32:40.00 [BUILD|0] -----> Writing config/database.yml to read from DATABASE_URL
04/20 22:32:41.31 [BUILD|0] ###### WARNING:
04/20 22:32:41.31 [BUILD|0]        You have the `.bundle/config` file checked into your repository
04/20 22:32:41.31 [BUILD|0]        It contains local state like the location of the installed bundle
04/20 22:32:41.31 [BUILD|0]        as well as configured git local gems, and other settings that should
04/20 22:32:41.31 [BUILD|0]        not be shared between multiple checkouts of a single repo. Please
04/20 22:32:41.31 [BUILD|0]        remove the `.bundle/` folder from your repo and add it to your `.gitignore` file.
04/20 22:32:41.31 [BUILD|0]        https://devcenter.heroku.com/articles/bundler-configuration
04/20 22:32:58.50 [BUILD|0] Exit status 0
04/20 22:32:59.45 [DROPLET|0] Uploaded /tmp/droplet to http://local.lattice.cf:8444/blobs/helloruby-droplet.tgz.
04/20 22:32:59.49 [DROPLET|0] Exit status 0# tc list-droplets
Droplet        Created At        Size
helloruby    04/20 14:32:59.00    20.3M

2. 启动droplet

# ltc launch-droplet helloruby helloruby
No port specified. Defaulting to 8080.
Creating App: helloruby
.04/20 22:37:00.15 [APP|0] Creating container
.04/20 22:37:01.77 [APP|0] Successfully created container
..............04/20 22:37:16.10 [HEALTH|0] healthcheck failed
04/20 22:37:16.14 [HEALTH|0] Exit status 1
04/20 22:37:16.56 [SSH|0] {"timestamp":"1461163036.562246799","source":"sshd","message":"sshd.started","log_level":1,"data":{}}
04/20 22:37:16.81 [HEALTH|0] healthcheck failed
04/20 22:37:16.83 [HEALTH|0] Exit status 1
.04/20 22:37:17.54 [HEALTH|0] healthcheck failed
04/20 22:37:17.57 [HEALTH|0] Exit status 1
.04/20 22:37:18.04 [APP|0] I, [2016-04-20T14:37:18.041860 #10]  INFO -- : Refreshing Gem list
04/20 22:37:18.26 [APP|0] I, [2016-04-20T14:37:18.253960 #10]  INFO -- : listening on addr=0.0.0.0:8080 fd=9
04/20 22:37:18.27 [APP|0] I, [2016-04-20T14:37:18.266758 #10]  INFO -- : master process ready
04/20 22:37:18.27 [HEALTH|0] healthcheck passed
04/20 22:37:18.31 [APP|0] I, [2016-04-20T14:37:18.280764 #43]  INFO -- : worker=0 ready
04/20 22:37:18.32 [APP|0] I, [2016-04-20T14:37:18.284959 #49]  INFO -- : worker=2 ready
04/20 22:37:18.33 [APP|0] I, [2016-04-20T14:37:18.305195 #46]  INFO -- : worker=1 ready
04/20 22:37:18.35 [HEALTH|0] Exit status 0helloruby is now running.
App is reachable at:
http://helloruby.local.lattice.cf
http://helloruby-8080.local.lattice.cf

Ruby App启动成功,可以通过http://helloruby.local.lattice.cf访问应用





 

这篇关于CloudFoundry in 1 Box简介:Lattice篇的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/262258

相关文章

Golang的CSP模型简介(最新推荐)

《Golang的CSP模型简介(最新推荐)》Golang采用了CSP(CommunicatingSequentialProcesses,通信顺序进程)并发模型,通过goroutine和channe... 目录前言一、介绍1. 什么是 CSP 模型2. Goroutine3. Channel4. Channe

Java中的Opencv简介与开发环境部署方法

《Java中的Opencv简介与开发环境部署方法》OpenCV是一个开源的计算机视觉和图像处理库,提供了丰富的图像处理算法和工具,它支持多种图像处理和计算机视觉算法,可以用于物体识别与跟踪、图像分割与... 目录1.Opencv简介Opencv的应用2.Java使用OpenCV进行图像操作opencv安装j

ASIO网络调试助手之一:简介

多年前,写过几篇《Boost.Asio C++网络编程》的学习文章,一直没机会实践。最近项目中用到了Asio,于是抽空写了个网络调试助手。 开发环境: Win10 Qt5.12.6 + Asio(standalone) + spdlog 支持协议: UDP + TCP Client + TCP Server 独立的Asio(http://www.think-async.com)只包含了头文件,不依

业务协同平台--简介

一、使用场景         1.多个系统统一在业务协同平台定义协同策略,由业务协同平台代替人工完成一系列的单据录入         2.同时业务协同平台将执行任务推送给pda、pad等执行终端,通知各人员、设备进行作业执行         3.作业过程中,可设置完成时间预警、作业节点通知,时刻了解作业进程         4.做完再给你做过程分析,给出优化建议         就问你这一套下

容器编排平台Kubernetes简介

目录 什么是K8s 为什么需要K8s 什么是容器(Contianer) K8s能做什么? K8s的架构原理  控制平面(Control plane)         kube-apiserver         etcd         kube-scheduler         kube-controller-manager         cloud-controlle

【Tools】AutoML简介

摇来摇去摇碎点点的金黄 伸手牵来一片梦的霞光 南方的小巷推开多情的门窗 年轻和我们歌唱 摇来摇去摇着温柔的阳光 轻轻托起一件梦的衣裳 古老的都市每天都改变模样                      🎵 方芳《摇太阳》 AutoML(自动机器学习)是一种使用机器学习技术来自动化机器学习任务的方法。在大模型中的AutoML是指在大型数据集上使用自动化机器学习技术进行模型训练和优化。

论文翻译:ICLR-2024 PROVING TEST SET CONTAMINATION IN BLACK BOX LANGUAGE MODELS

PROVING TEST SET CONTAMINATION IN BLACK BOX LANGUAGE MODELS https://openreview.net/forum?id=KS8mIvetg2 验证测试集污染在黑盒语言模型中 文章目录 验证测试集污染在黑盒语言模型中摘要1 引言 摘要 大型语言模型是在大量互联网数据上训练的,这引发了人们的担忧和猜测,即它们可能已

SaaS、PaaS、IaaS简介

云计算、云服务、云平台……现在“云”已成了一个家喻户晓的概念,但PaaS, IaaS 和SaaS的区别估计还没有那么多的人分得清,下面就分别向大家普及一下它们的基本概念: SaaS 软件即服务 SaaS是Software-as-a-Service的简称,意思是软件即服务。随着互联网技术的发展和应用软件的成熟, 在21世纪开始兴起的一种完全创新的软件应用模式。 它是一种通过Internet提供

LIBSVM简介

LIBSVM简介 支持向量机所涉及到的数学知识对一般的化学研究者来说是比较难的,自己编程实现该算法难度就更大了。但是现在的网络资源非常发达,而且国际上的科学研究者把他们的研究成果已经放在网络上,免费提供给用于研究目的,这样方便大多数的研究者,不必要花费大量的时间理解SVM算法的深奥数学原理和计算机程序设计。目前有关SVM计算的相关软件有很多,如LIBSVM、mySVM、SVMLight等,这些

urllib与requests爬虫简介

urllib与requests爬虫简介 – 潘登同学的爬虫笔记 文章目录 urllib与requests爬虫简介 -- 潘登同学的爬虫笔记第一个爬虫程序 urllib的基本使用Request对象的使用urllib发送get请求实战-喜马拉雅网站 urllib发送post请求 动态页面获取数据请求 SSL证书验证伪装自己的爬虫-请求头 urllib的底层原理伪装自己的爬虫-设置代理爬虫coo