Pivotal Web Service主管工程师 产品经理 吴疆
在《CloudFoundry in 1 Box简介:Bosh-lite篇》我们介绍了Bosh-lite的架构和部署。在本篇中,我们将详细描述另一个CloudFoundry in 1 Box解决方案PCF-Dev。
1. PCF-dev简介
PCF是Pivotal发行的Cloud Foundry商业版,PCF-Dev原名MicroPCF,是Pivotal为PCF的应用开发人员准备的一款App单虚拟机版的CloudFoundry。但是,麻雀虽小,五脏俱全。PCF-Dev虽然可以在仅仅一台虚拟式上即可运行,但是却包含了cloud foundry完整的技术栈。下图展示了PCF-Dev的架构
在PCF-Dev中,除了包含了完整的Cloud Foundry,还包含了下列Cloud Foundry Service
和一系列Buildpack
Java
Ruby
Python
Golang
Static file
Binary
PCF-Dev不仅功能强大,使用起来却是异常简便。下面我们就来一步一步搭建一个PCF-Dev环境。
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. 部署PCF-Dev
3.1 从pivotal network下载PcF-dev
Pivotal Network地址:http://network.pivotal.io
3.2 解压pcf-dev
3.3 启动pcf-dev
# cd <pcf-dev>
# ./start-osx #在linux也可以正常工作
3.4 查看PCF-dev component
# cd <pcf-dev>
# vagrant ssh ##登陆pcf-dev虚拟机
# 登陆之后的pcf-dev虚拟机
$ sudo -i
# monit summary
root@agent-id-pcfdev-0:~# monit summary
The Monit daemon 5.2.5 uptime: 14m
Process 'consul_agent' running
Process 'cloud_controller_clock' running
Process 'cloud_controller_ng' running
Process 'cloud_controller_worker_local_1' running
Process 'cloud_controller_worker_local_2' running
Process 'nginx_cc' running
Process 'cloud_controller_migration' running
Process 'cloud_controller_worker_1' running
Process 'doppler' running
Process 'gorouter' running
Process 'loggregator_trafficcontroller' running
Process 'metron_agent' running
Process 'nats' running
Process 'postgres' running
Process 'route_registrar' running
Process 'routing-api' running
Process 'uaa' running
Process 'etcd' running
Process 'garden' running
Process 'auctioneer' running
Process 'bbs' running
Process 'cc_uploader' running
Process 'converger' running
Process 'file_server' running
Process 'nsync_listener' running
Process 'nsync_bulker' running
Process 'rep' running
Process 'route_emitter' running
Process 'ssh_proxy' running
Process 'stager' running
Process 'tps_listener' running
Process 'tps_watcher' running
Process 'syslog-configurator' running
Process 'process-watcher' running
Process 'cf-redis-broker' running
Process 'broker-nginx' running
Process 'cf-redis-route-registrar' running
Process 'cf-mysql-broker' running
Process 'cf-mysql-route-registrar' running
Process 'quota-enforcer' running
Process 'mariadb_ctrl' running
Process 'galera-healthcheck' running
Process 'gra-log-purger-executable' running
Process 'rabbitmq-broker' running
Process 'rabbitmq-broker-route-registrar' running
Process 'rabbitmq-management-route-registrar' running
Process 'rabbitmq-server' running
System 'system_localhost' running
启动后的PCF-Dev虚拟机配置了两块网卡,一块用来连接CloudFoundry网络,使用10.0.2.15/24;一块用来和宿主机通信,使用IP 192.168.11.11
如果设有http https proxy,需要执行如下步骤
export no_proxy=192.168.11.11,local.pcfdev.io
至此,PCF-Dev环境准备完毕。
4. 部署app到PCF-Dev
4.1 安装CF CLI
#rpm -Uvh https://s3.amazonaws.com/go-cli/releases/v6.16.1/cf-cli-installer_6.16.1_x86-64.rpm
4.2 cf target
PCF-Dev默认的域名为local.pcfdev.io, *.local.pcfdev.io会被解析到192.168.11.11
# ping xyz.local.pcfdev.io
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
# cf api https://api.local.pcfdev.io --skip-ssl-validation
Setting api endpoint to api.local.pcfdev.io...
OK
API endpoint: https://api.local.pcfdev.io (API version: 2.51.0)
Not logged in. Use 'cf login' to log in.
# cf login ##username/password are admin/admin
API endpoint: https://api.local.pcfdev.io
Email> admin
Password>
Authenticating...
OK
Targeted org pcfdev-org
Targeted space pcfdev-space
API endpoint: https://api.local.pcfdev.io (API version: 2.51.0)
User: admin
Org: pcfdev-org
Space: pcfdev-space
4.3 部署App
# cd <app>
# cf push
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。