Download presentation
Presentation is loading. Please wait.
1
用BOSH自动部署大规模 云平台Cloud Foundry
Henry Zhang, VMWare, China @张轩宁的围脖 Jacky Li, VMWare, China
2
演讲内容 Cloud Foundry云平台简介 Cloud Foundry架构 Cloud Foundry部署模型 BOSH工作原理
用BOSH自动化部署Cloud Foundry 用BOSH实现Cloud Foundry弹性 BOSH应用实例
3
Cloud Foundry 云平台简介
4
应用的复杂度: 开发 Sound architecture: future proofing without overdoing
Unit and integration tests Responding to changing business needs Confusing technology landscape
5
应用的复杂度:部署和运维 Choosing the right hardware, operating system, web server
Monitoring applications Responding to scalability needs Dealing with hardware- and system-level failures Upgrading without substantial down time
6
Implementation overhead
内在的和实际的复杂度 怎么办? Implementation overhead Implementation 实际的 复杂度 Functional logic 内在的 复杂度
7
云计算的三个层次 SaaS Software as a Service PaaS Platform as a Service IaaS Infrastructure as a Service Cloud computing as most vendors describe it breaks down into three fundamental layers. You’ve probably seen this before, so we’ll be brief. At the top, we have SaaS, or Software as a Service. This is layer that faces consumers and has been around the longest. The .com buzz in the 90s was an early form of SaaS. Instead of installing software onto a computer, we interact with a server via a web browser. Instead of Outlook on a desktop, we use GMail in a browser. At the bottom, we have Infrastructure as a Service. This is about moving away from physical machines in a data center to virtualized compute resources. Need a new server? Avoid the P.O. and just buy access to someone else’s compute resources. Amazon’s EC2 is king in the public space, VMware’s vSphere is dominate in the enterprise and Open Stack is the new incumbent. So if SaaS targets consumers and MBAs, IaaS targets sysadmins, what about developers? That’s where PaaS or Platform as a Service fits in. PaaS is the youngest of these layers and makes it easy to deploy applications without installing an operating system, application server or database servers. PaaS is what this talk is about.
8
Cloud Foundry 开放 PaaS Private Clouds Cloud Provider Interface
Data Services Private Clouds Msg Services Cloud Provider Interface Public Clouds Application Service Interface Other Services Micro Clouds
9
Cloud Foundry 开放 PaaS Private Clouds Cloud Provider Interface
Data Services Private Clouds Partners Msg Services Cloud Provider Interface Public Clouds Application Service Interface Other Services Micro Clouds Apache2 license
10
Cloud Foundry 的架构
11
Cloud Foundry 层次 Clients Inner Shell (CF) Outer Shell (BOSH)
Infrastructure as a Service Hardware (CPU, Memory, Storage, Network)
12
Cloud Foundry 内壳(Inner Shell)
Developers Users Routers CloudControllers Stagers App App HealthManager Services Execution Agents (DEA) Pool Messaging
13
Cloud Foundry内部架构 cloud stager controller health manager cc - db
App meta data staging jobs redis cc - db cloud controller stager package cache blobstore uaa - db dea health manager staging logs uaa - AuthN dea dea dea dea dea Staging: creating a runnable application, bundler, modify a DB cofig. Like bookstore We stick the user/pass connection, you don’t this. Works for Java Packaged cache – “foo packaged in rails” Blobstore – where the app is ready to run with all of it’s depndecies, it’s packaged up in the blob store and DEA fetch it for execution App meta data – CC tells the DEA tells this is a java app
14
设计原则 可动态发现组件 组件之间无依赖性 启动顺序无关 各组件独立的扩展
15
Cloud Foundry部署模型
16
Cloud Foundry 组件模型 ccdb cloud controller stager uaa nats router
health manager dea app service Multiple node types Multiple instances of most node type
17
Cloud Foundry 部署模型(1)- 单结点
OS Single node deployment model 单虚拟机或物理机
18
Cloud Foundry 部署模型(2)- 多结点
VM ccdb VM cloud controller VM stager VM stager VM cloud controller VM stager VM uaa VM nats VM router VM router VM health manager VM dea VM service VM dea VM service VM dea VM service VM service VM dea Multi node deployment model 每台虚拟机(或物理机)部署一个或数个组件
19
CloudFoundry.com生产系统部署的实例
500 – 5,000 VMs 40+ unique node types 75+ unique software packages 75+ unique environments Small team
20
Cloud Foundry两种部署方法(1)
dev_setup 手工部署 直接在操作系统(ubuntu 10.04)中用脚本部署 可部署单结点或多结点 适合小规模实验的环境 支持虚拟机和物理机 每台机器需要手工安装和修改配置文件 系统扩容能力和弹性计算较差
21
Cloud Foundry两种部署方法(2)
BOSH 自动部署 自动化大规模部署多结点系统 集中式的配置文件 支持自动化系统扩容 仅支持虚拟机 对各类IaaS平台集成 (CPI) 在Cloudfoundry.com生产系统中使用
22
BOSH工作原理
23
BOSH is a recursive definition of
BOSH Outter SHell
24
BOSH是大规模自动化管理工具 来自Cloud Foundry的开源项目 通用的自动化部署工具链 可以部署多种软件
Gerrit, Jenkins, Wordpress, MySQL, …
25
BOSH在Cloud Foundry中的作用
部署系统 更新配置 版本管理 监控运行
26
BOSH的内部结构
27
BOSH部署原理(1) BOSH BOSH是部署系统的总指挥 管理员通过BOSH CLI工具发送 指令给BOSH BOSH CLI
Operation Staff BOSH是部署系统的总指挥 管理员通过BOSH CLI工具发送 指令给BOSH
28
BOSH部署原理(2) IaaS BOSH CPI ( Cloud Provider Interface)支持多种 IaaS
BOSH通过CPI管理IaaS层资源(虚拟机、虚拟 存储、虚拟网络等) BOSH CLI BOSH Operation Staff CPI IaaS 创建虚拟机 CPI ( Cloud Provider Interface)支持多种 IaaS BOSH通过CPI管理IaaS层资源(虚拟机、虚拟存 储、虚拟网络等)
29
BOSH部署原理(3) VM VM VM VM IaaS BOSH BOSH调用CPI动态生成虚拟机
BOSH CLI BOSH Operation Staff CPI Inner Shell VM VM VM VM BOSH调用CPI动态生成虚拟机 Inner Shell – 被管理的部分 . . . IaaS 创建虚拟机 BOSH调用CPI动态生成虚拟机 Inner Shell – 被管理的部分
30
BOSH部署原理(4) VM VM VM VM IaaS BOSH Stemcell提供虚拟机模板
BOSH CLI BOSH Operation Staff Deployment Stemcell CPI Inner Shell VM VM VM VM Stemcell提供虚拟机模板 Deployment manifest定义部署细 节: IP地址、用户名/密码等 . . . IaaS 创建虚拟机 Stemcell提供虚拟机模板 Deployment manifest定义部署细节: IP地址、用 户名/密码等
31
BOSH部署原理(5) VM VM VM VM IaaS BOSH CLI BOSH 每个虚拟机内嵌一个Agent
Operation Staff Stemcell CPI Deployment Inner Shell VM Agent VM Agent VM Agent VM Agent 每个虚拟机内嵌一个Agent 负责管理、控制、监控虚拟机 . . . IaaS 创建虚拟机 每个虚拟机内嵌一个Agent 负责管理、控制、监控虚拟机
32
BOSH部署原理(6) VM VM VM VM IaaS BOSH CLI BOSH Agent接收BOSH的指令
Operation Staff Stemcell CPI Deployment Inner Shell VM Agent VM Agent VM Agent VM Agent Agent接收BOSH的指令 完成软件部署安装、应用起停、 系统监控等任务 . . . IaaS 创建虚拟机 Agent接收BOSH的指令 完成软件部署安装、应用起停、系统监控等任务
33
BOSH部署原理(7) VM VM VM VM IaaS BOSH CLI BOSH
Operation Staff Stemcell CPI Deployment Inner Shell Release VM Agent VM Agent VM Agent VM Agent . . . Release包含软件的源代码、 目标码、版本、配置等信息 IaaS 创建虚拟机 Release包含软件的源代码、目标码、版本、配置等信息
34
Cloud Foundry平台的升级过程
35
滚动式升级:无状态(Stateless)组件
Message Bus Cloud Controller v1 Starting with v1 VMs Router Incoming HTTP Requests Message Bus Cloud Controller v1 Cloud Controller v2 Deploy a v2 VM (canary) Create Router Incoming HTTP Requests Message Bus Cloud Controller v1 Cloud Controller v2 If it works, add more v2 VMs... Create Router Incoming HTTP Requests
36
例子:Cloud Controller 结果: 从v1升级到v2, 创建了新的虚拟机,中间没有宕机时间。
Message Bus Cloud Controller v2 … until all VMs are v2 Router / LB Incoming HTTP Requests Incoming HTTP Requests Router / LB 结果: 从v1升级到v2, 创建了新的虚拟机,中间没有宕机时间。 Destroy Create Cloud Controller v1 Cloud Controller v2 Message Bus … while removing v1 VMs…
37
部署要点 并行升级 金丝雀(Canaries) 最终一致性 (Eventual consistency)
38
有状态和无状态的VM 无状态(stateless)VM 有状态(stateful)的VM 没有持久化数据,
具有持久化的磁盘(如数据库数据) 升级时需要保留持久化的磁盘
39
代码升级(不涉及数据)
40
Stateful VM 升级
41
VM 更新
42
用BOSH自动化部署Cloud Foundry (vSphere)
43
BOSH的内部结构 BOSH由6个虚拟机组成
44
安装BOSH的步骤 安装BOSH CLI (Ubuntu 10.04) 部署Micro BOSH (单个VM)
部署多结点分布式BOSH (6个VMs) Micro BOSH VM BOSH VM BOSH CLI
45
准备工作 - 软件 64-bit Ubuntu 10.04 LTS, better in ISO format.
vSphere V4.1 or V5.x, vSphere client vCenter (installed on a Win2008 R2 64bit or a Win2003 server, physical or virtual machine)
46
准备工作 – 硬件(1) * Cloud Foundry需要最少的结点数,实际中可能会更多。 # of nodes OS
# of nodes OS Can be physical machine? BOSH CLI 1 Ubuntu Y vCenter+vSphere Client Win2008 Y, can be split into two nodes micro BOSH N BOSH 6 Cloud Foundry 34* N, see notes Total: 43 * Cloud Foundry需要最少的结点数,实际中可能会更多。
47
准备工作 – 硬件(2) 物理服务器配置估算: 假定,每台虚拟机4GB内存,1 vCPU, 则大约需要
4 x 43 = 172 GB RAM, 1 x 43 = 43 vCPU,因此可以选用 6 台物理服务器:每台 8 核CPU,32GB RAM. 较小配置 (部署实验环境) 每台虚拟机256MB内存, 1台物理服务器: 8 核CPU,16GB RAM. 注:CPU在试验环境中不是最关键资源
48
准备工作 – 网络 建议分配4个VLAN 足够的IP地址 结点之间可以连通,没有防火墙 vSphere网络名称必须相同
必须直接连接 Internet (很重要!) VLAN Nodes Management VLAN Hypervisors and NFS storage CF VLAN BOSH VMs, and VMs of cloud foundry Service VLAN For LB, dual-home routers Public VLAN For LB, incoming requests
49
准备工作 – 网络 (2) 参考网络拓扑图
50
准备工作 – 网络 (3) vSphere 配置
51
准备工作 – 存储 vSphere vSphere vSphere vSphere 建议用NFS存储
所有的vSphere在vCenter中组成一个Cluster 所有vSphere挂接同样的NFS mount point 在vSphere中存储必须用同样的名字 Cluster vSphere vSphere vSphere vSphere NFS
52
准备工作 – 存储(2) vSphere 配置
53
安装 – BOSH CLI 创建一个干净的虚拟机 安装Ubuntu 10.04 安装Ruby环境 安装BOSH CLI工具
记住: 虚拟机要直接连接Internet
54
安装 – Micro BOSH 通过BOSH CLI里面的工具Bosh_deployer,安装Micro BOSH
完成后, vCenter中可以看到Micro BOSH虚拟机 记住: 虚拟机要直接连接Internet DEMO: Stemcell的下载 $ bosh public stemcells $ bosh download public stemcell micro-bosh-stemcell tgz 输出大致如下 : | Name | Url | | bosh-stemcell tgz | | | bosh-stemcell-aws tgz | | | bosh-stemcell-vsphere tgz | | | micro-bosh-stemcell tgz | | To download use 'bosh download public stemcell<stemcell_name>'.For full url use --full.
55
安装 – BOSH 通过Micro BOSH安装分布式 BOSH (6 VMs) 需要规划6台虚拟机的网络以及存储
规划Resource Pools Pool Name Size Configuration Jobs small 3 RAM:512MB, CPU:1, DISK:2GB nats, redis, health_monitor medium 2 RAM:1GB, CPU: 1, DISK: 8GB postgres, blobstore director 1 RAM:2GB, CPU: 2, DISK: 8GB
56
安装 – BOSH (2) 每个job占用一台虚拟机 把job分配到Resource Pool Job Resource_pool IP
nats small postgres medium redis director blob_store health_monitor
57
安装 – BOSH (3) 编写deployment manifest的yml文件 参考gitHub上面的样板 启动部署
58
安装 – Cloud Foundry 通过BOSH安装分布式 Cloud Foundry (34+ VMs)
需要规划所有虚拟机的网络以及存储 规划Resource Pools Pool Name Size Configuration Jobs small 32 RAM:1GB, CPU: 1, DISK: 8GB Nats, router, ccdb_postgres uaadb vcap_redis Uaa等30个jobs medium 4 RAM:2GB, CPU: 2, DISK: 16GB debian_nfs_server cloud_controller dea
59
安装 – Cloud Foundry (2) 规划每个job的配置:实例数、资源分配、网络等 必 要 的 可 选 的
60
安装 – Cloud Foundry(3) 编写deployment manifest 参考gitHub上面的样板
61
DEMO 下载Cloud Foundry release开源代码 Create release Upload release
Deploy CF
62
BOSH部署完成之后的Cloud Foundry (vCenter)
vCenter view of Cloud Foundry
63
BOSH部署完成之后的Cloud Foundry (BOSH CLI)
Command: bosh vms
64
BOSH的监控功能 虚拟机里的agent 发送心跳信息 采集系统数据 数据汇总
65
实现Cloud Foundry弹性计算
66
Cloud Foundry 云平台的弹性 包含整个Cloud Foundry云平台 大规模部署Cloud Foundry云平台 单虚拟机
Open source Platform as a Service project App Instances Services 包含整个Cloud Foundry云平台 单虚拟机 大规模部署Cloud Foundry云平台 多达数千个虚拟机结点
67
Cloud Foundry 云平台弹性的原理
BOSH动态增加DEA结点,可承载更多云应用 BOSH动态增加Service结点,可提供更多云服务 DEA IaaS DEA BOSH IaaS Svc If all DEAs are fully loaded, so we scale up with increasing number of DEA nodes IaaS
68
Cloud Foundry 云平台弹性的原理
BOSH动态增加DEA结点,可承载更多云应用 BOSH动态增加Service结点,可提供更多云服务 DEA DEA Svc IaaS DEA BOSH IaaS Svc If all DEAs are fully loaded, so we scale up with increasing number of DEA nodes IaaS
69
BOSH实现Cloud Foundry平台弹性
更新deployment manifest中dea和services实例数 更新Resource pool 大小 启动BOSH update 例子:在Cloud Foundry中增加2个dea结点的方法,修改yml文件: - name: dea template: dea instances: 2 4 resource_pool: medium networks: - name: default static_ips: resource_pools: - name: medium network: default size: 5 7 Update yml file to reflect the system changes, then do a command: $ bosh update
70
BOSH在Cloud Foundry项目开发中的应用
71
Bosh在测试平台上的应用 整个测试开发平台是由Bosh 部署的
72
测试平台的资源分配 节点 数量 资源池 CPU(核) 内存 系统盘 数据盘 2 小 1 2G 4G 128M 8G 中 4 16G 24G
nginx 2 小 1 2G 4G 128M gerrit_mysql 8G gerrit_mysql_slave gerrit_replication gerrit 中 4 16G 24G jenkins 32G jenkins_slave 8 大 64G 72
73
端到端bosh自动部署测试用例 Micro Bosh Bosh Director Cloud Foundry CF BAT 73
74
端到端Bosh自动部署测试用例 74
75
总结 BOSH可以部署复杂的系统,如Cloud Foundry BOSH可以用来部署自身 BOSH可以部署、管理、扩展系统
76
用BOSH部署Cloud Foundry完全手册
77
Cloud Foundry中文资源 微博:@cloudfoundry 网站:http://www.cloudfoundry.cn/
博客: 社区: 文档: 视频:
78
http://cloudfoundry.com/si gnup
注册并使用Cloud Foundry gnup 使用下面推广码 可马上获得批准: CFCN
79
Thank You!
Similar presentations