热门IT资讯网

CloudFoundry in 1 Box简介:PCF-Dev篇

发表于:2024-11-24 作者:热门IT资讯网编辑
编辑最后更新 2024年11月24日,Pivotal Web Service主管工程师 产品经理 吴疆在《CloudFoundry in 1 Box简介:Bosh-lite篇》我们介绍了Bosh-lite的架构和部署。在本篇中,我们将详细

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


  • MySQL

  • Redis

  • RabbitMQ


和一系列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 --versionVagrant 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/# rpm -Uvh VirtualBox-5.0-5.0.16_105871_el7-1.x86_64.rpm


验证virtualbox是否安装成功

# VBoxManage --version5.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 # ./start-osx #在linux也可以正常工作


3.4 查看PCF-dev component

# cd # vagrant ssh ##登陆pcf-dev虚拟机# 登陆之后的pcf-dev虚拟机$ sudo -i# monit summaryroot@agent-id-pcfdev-0:~# monit summaryThe Monit daemon 5.2.5 uptime: 14mProcess 'consul_agent'              runningProcess 'cloud_controller_clock'    runningProcess 'cloud_controller_ng'       runningProcess 'cloud_controller_worker_local_1' runningProcess 'cloud_controller_worker_local_2' runningProcess 'nginx_cc'                  runningProcess 'cloud_controller_migration' runningProcess 'cloud_controller_worker_1' runningProcess 'doppler'                   runningProcess 'gorouter'                  runningProcess 'loggregator_trafficcontroller' runningProcess 'metron_agent'              runningProcess 'nats'                      runningProcess 'postgres'                  runningProcess 'route_registrar'           runningProcess 'routing-api'               runningProcess 'uaa'                       runningProcess 'etcd'                      runningProcess 'garden'                    runningProcess 'auctioneer'                runningProcess 'bbs'                       runningProcess 'cc_uploader'               runningProcess 'converger'                 runningProcess 'file_server'               runningProcess 'nsync_listener'            runningProcess 'nsync_bulker'              runningProcess 'rep'                       runningProcess 'route_emitter'             runningProcess 'ssh_proxy'                 runningProcess 'stager'                    runningProcess 'tps_listener'              runningProcess 'tps_watcher'               runningProcess 'syslog-configurator'       runningProcess 'process-watcher'           runningProcess 'cf-redis-broker'           runningProcess 'broker-nginx'              runningProcess 'cf-redis-route-registrar'  runningProcess 'cf-mysql-broker'           runningProcess 'cf-mysql-route-registrar'  runningProcess 'quota-enforcer'            runningProcess 'mariadb_ctrl'              runningProcess 'galera-healthcheck'        runningProcess 'gra-log-purger-executable' runningProcess 'rabbitmq-broker'           runningProcess 'rabbitmq-broker-route-registrar' runningProcess 'rabbitmq-management-route-registrar' runningProcess 'rabbitmq-server'           runningSystem '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.ioPING 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 ms64 bytes from 192.168.11.11: icmp_seq=2 ttl=64 time=1.45 ms64 bytes from 192.168.11.11: icmp_seq=3 ttl=64 time=1.33 ms64 bytes from 192.168.11.11: icmp_seq=4 ttl=64 time=1.69 ms64 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 4006msrtt min/avg/max/mdev = 0.818/1.311/1.696/0.292 ms
# cf api https://api.local.pcfdev.io --skip-ssl-validationSetting api endpoint to api.local.pcfdev.io...OKAPI 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/adminAPI endpoint: https://api.local.pcfdev.ioEmail> adminPassword>Authenticating...OKTargeted org pcfdev-orgTargeted space pcfdev-spaceAPI endpoint:   https://api.local.pcfdev.io (API version: 2.51.0)User:           adminOrg:            pcfdev-orgSpace:          pcfdev-space


4.3 部署App

# cd # cf push



0