原文:http://docs.cloudfoundry.com/docs/running/bosh/
BOSH用于发布,部署,及大规模分布式服务对象的生命周期管理,它可用于部署CF,也可以将其它分布式服务(?PaaS)部署到IaaS(VMware vSphere,vCloud Director,Amazon Web Services EC2,OpenStack)上。
下面针对它的架构,拓扑结构,配置及使用,以及部署过程中的结构与约定。
BOSH Components(BOSH的组成部分)
Director
The Director is the core orchestrating(协调) component in BOSH.
It controls creation of VMs, deployment, and other life cycle events of software and services.
Command and control is handed over to the the Director-Agent interaction after the CPI(CF提供的操作IaaS的接口 ) has created resources.
--管理VM的创建与服务的生命周期,它通过Director-Agent执行这些命令。
下面展示具体工作的负责子模块,它们被一个叫做ApiController的实例引用着。
Deployment Manager
Responsible for creating, updating, and deleting the deployments that are specified in the deployment file. Endpoints and Http Method type exposed by the director that are used to access the Deployment Manager are described below.(下面是提供的REST接入点)
URL | HTTP METHOD TYPE | DESCRIPTION |
/deployments | POST | |
/deployments/:deployment/jobs/:job | PUT | Change the state of a job in a deployment based on the parameter |
/deployments/:deployment/jobs/:job/:index/logs | GET | Get logs of a particular job in a deployment |
/deployments/:name | DELETE | Delete a deployment |
Instance Manager
Instance Manager helps manage VM instances that are created using Bosh deployments.
It helps connect to the VM instance through an Agent Client using ssh, finds an instance, and fetches the log from a particular instance.
The figure below describes the flow when a user tries to SSH into a VM using Bosh CLI.
--(这里的实例是VM实例),实例管理子模块负责管理VM的实例,使用ssh连接VM所在机器上的Agent Client,进而可查找实例,或者获取实例的日志。
下面展示SSH到VM的示意图。
Problem Manager
This component helps scan a deployment for problems and helps apply resolutions. It uses a model deployment_problem to keep info about the problem and has a one-to-many relationship with Deployment Model.
--部署产生的问题的管理模块,对象多个部署模型。
Property Manager
Properties are attributes specified for jobs in the deployment file. The Property Manager allows you to find properties associated with a deployment and update a particular property for a deployment. It references the Deployment Manager.
--从部署文件中抽取出的一些属性值,用于jobs。也可更新指定的属性,这个子模块持有对应的Deployment Manager。
Resource Manager
The Resource Manager provides access to the resources stored in the BlobStore. Some of the actions performed through a resource manager are:
- Get a Resource using an ID
- Delete a resource by giving an resource ID
- Get the resource path from an ID
--对BlobStore打交道,通常执行上面三个操作。
Release(发布) Manager
The Release Manager manages the creation and deletion of releases. Each release references a Release Manager and contains a Deployment Plan object as well as an array of templates.
--管理发布的创建与删除,它包含一份部署计划,以及一系列的模板文件。
The Director routes the request coming at the following endpoints to the release manager for managing the release lifecycle.
--下面是REST 接入URI
URL | HTTP METHOD TYPE | RESPONSE BODY | DESCRIPTION |
/releases | GET | {“name” => release.name,“versions” => versions, “in_use” => versions_in_use} | Get the list of all releases uploaded |
/releases | POST | Create a release for the user specified. |
Lifecycle of a Release
The figure below shows the interaction between various components of a Director when a release is created/ updated or deleted.
--下图展示当创建/更新/删除一个发布时,多个子模块的交互示意
Stemcell(干细胞) Manager
The Stemcell Manager manages the Stem cells. It is responsible for creating, deleting, or finding a stemcell.
下图展示它的工作示意
REST API
URL | HTTP METHOD TYPE | RESPONSE BODY | DESCRIPTION |
/stemcells | GET | { “name” => stemcell.name, “version” => stemcell.version, “cid” => stemcell.cid} | Json specifying the stemcell name, version and cid of the stem cell. |
/stemcells | POST | Stemcell binary file | |
/stemcells | DELETE | Delete the specified stemcell |
Task Manager
The Task Manager is responsible for managing the tasks which are created and are being run by the Job Runner.
--管理创建的任务,这些任务将会由Job Runner去完成
REST API
URL | HTTP METHOD TYPE | RESPONSE BODY | DESCRIPTION |
/tasks | GET | Get all the tasks being executed of type"update_deployment", “delete_deployment”, “update_release”,“delete_release”, “update_stemcell”, “delete_stemcell” | |
/tasks/:id | GET | Send back output for a task with the given id | |
/tasks/:id/output | GET | Sends back output of given task id and params[:type] | |
/task/:id | DELETE | Delete the task specified by a particular Id |
User Manager
- Create a User
- Delete a User
- Authenticate a User
- Get a User
- Update a User
REST API
URL | HTTP METHOD TYPE | HTTP REQUEST BODY | DESCRIPTION |
/users | POST | Create a User | |
/users/:username | PUT | Update a User | |
/users/:username | DELETE | Delete a User |
--这里的用户是什么概念?
VM State Manager
Helps fetch the VM State by creating a task which runs the Hob : VmState
The vm state is fetched by creating a GET request on the /deployments/:name/vms endpoint in the Director. name is the name of the deployment.
Messaging
BOSH uses the NATS message bus for command and control.
Health Monitor
The BOSH Health Monitor receives health status and life cycle events from the BOSH Agent and can send alerts through notification plugins (such as email). The Health Monitor has a simple awareness of events in the system, so as not to alert if a component is updated.
--接收BOSH Agent上传的健康状态,可接收操作产生的事件
Stemcell(干细胞)
A Stemcell is a VM template with an embedded BOSH Agent. The Stemcell used for Cloud Foundry is a standard Ubuntu 10.04 LTS distribution, but BOSH also produces stemcells for CentOS 6.4 on some IaaS providers. Stemcells are uploaded using the BOSH CLI and used by the BOSH Director when creating VMs through the Cloud Provider Interface.
一个干细胞就是一个虚拟机模板,内置BOSH Agent,CF用Ubuntu 10.04作为虚拟机系统,也提供了CenOS6.4系统针对特定的IaaS。
十细胞通过CLI上传,在Director创建虚拟机调用CPI来使用它。
When the Director creates a VM through the CPI, it uses the machine image from the stemcell, and passes along configurations for networking and storage, as well as the location and credentials for the Message Bus and the Blobstore. The agent inside the VM invokes the Director when it boots and is provided settings and additional software that should be configured on the VM as specified by the jobs in the deployment manifest.
当Director使用CPI创建VM时,从干细胞产生的镜像被传递到目标端。当BOSH Agent随系统启动后,它调用Director获取设置或其它的软件,用于配置VM。这些设置在部署的manifest中。
Agent
BOSH Agents listen for instructions from the BOSH Director. Every VM contains an Agent. Through the Director-Agent interaction, VMs are given Jobs, or roles, within Cloud Foundry. If the VM's job is to run MySQL, for example, the Director will send instructions to the Agent about which packages must be installed and what the configurations for those packages are.
--Director与VM上的Agent进行交互,VM用于分配任务或角色。如果某VM的任务是进行MYSQL,Director会发送指令指出哪些包需要安装,以及怎么配置这些包。
Below is an 8 min video explaining the role of the Bosh Agent within each instance. It shows an example bosh deployment - deploying a single server running redis - and look at the high level explanation of how the bosh director communicates with the bosh agent, which communicates with monit, which starts and stops the redis server.--下面的视频agent的作用,它演示部署一个单server的redis,从中可看到director与agent的交互,与monit的交互,以及启动与停止redis服务。--看不了啊!!!
Blobstore
The BOSH Blobstore is used to store the content of Releases (BOSH Jobs and Packages in their source form as well as the compiled image of BOSH Packages. Releases are uploaded by the BOSH CLI and inserted into the Blobstore by the BOSH Director. When you deploy a Release, BOSH will orchestrate the compilation of packages and store the result in the Blobstore. When BOSH deploys a BOSH Job to a VM, the BOSH Agent will pull the specified Job and associated BOSH Packages from the Blobstore.
当部署一个发布时,BOSH会编译这些包并存储结果在Blobstore中,当BOSH部署一个BOSH Job到VM时,Agent接到指令后会拉这个Job对应的包。
BOSH also uses the Blobstore as an intermediate(中间过度) store for large payloads, such as log files (see BOSH logs) and output from the BOSH Agent that exceeds(超过) the max size for messages over the message bus.
--过程大数据也会被存在Blockstore中。
There are currently three Blobstores supported in BOSH:
- Atmos
- S3
- simple blobstore server
The default BOSH configuration uses the simple blobstore server
下面是每一种的配置,指出了S3与Atmos的配置,略....
Micro BOSH
All BOSH stemcells include all of the BOSH components. You will use Micro BOSH to deploy BOSH. Installation steps for Micro BOSH are included in the Cloud Foundry deployment procedures. See the appropriate procedure for your platform.