您好,登錄后才能下訂單哦!
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
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。