原文:http://blog.scottlowe.org/2014/05/01/an-introduction-to-openstack-heat/git
本文将简要地介绍OpenStack Heat. Heat项目提供协做服务,容许咱们能够自动地建立多个计算实例,逻辑网络,以及对其余的云服务的操做。请注意,这只是一个简要介绍—我不是Heat的专家,我只是想要分享一些基本信息以便读者能够更快的使用Heat.github
为了在如下的具体的例子中不至于产生困扰,咱们先从术语开始。数据库
之后这些介绍应该足以支持咱们下面的介绍。(OpenStack Heat文档有一个优秀的术语介绍)json
从架构来看,Heat有一些重要的组件:api
Heat-api组件实现OpenStack自然支持的REST API。该组件经过把API请求经由AMQP传送给Heat engine来处理API请求。安全
Heat-api-cfn组件提供兼容AWS CloudFormation的API,同时也会把API请求经过AMQP转发给heat engine。服务器
Heat-engine组件提供Heat最主要的协做功能。网络
全部这些组件一般安装在OpenStack的控制节点上,该节点同时也是Nova, Glance,Neutron等其余服务的API服务器。然而,据我所知,并无客观要求必要安装这些服务在同一个节点上。与其余多数的OpenStack服务相似,Heat也使用后台数据库来维护状态信息。架构
既然如今你已经对Heat的架构也有一个大概了解,让咱们来看一个我在本身的OpenStack环境里建立并测试过的一个Heat template的例子(在Ubuntu 12.04上运行OpenStack Havana版本,使用KVM和VMware NSX)。下面是完整的template。函数
{ "AWSTemplateFormatVersion" : "2010-09-09", "Description" : "Sample Heat template that spins up multiple instances and a private network (JSON)", "Resources" : { "heat_network_01" : { "Type" : "OS::Neutron::Net", "Properties" : { "name" : "heat-network-01" } },
"heat_subnet_01" : { "Type" : "OS::Neutron::Subnet", "Properties" : { "name" : "heat-subnet-01", "cidr" : "10.10.10.0/24", "dns_nameservers" : ["172.16.1.11", "172.16.1.6"], "enable_dhcp" : "True", "gateway_ip" : "10.10.10.254", "network_id" : { "Ref" : "heat_network_01" } } },
"heat_router_01" : { "Type" : "OS::Neutron::Router", "Properties" : { "admin_state_up" : "True", "name" : "heat-router-01" } },
"heat_router_01_gw" : { "Type" : "OS::Neutron::RouterGateway", "Properties" : { "network_id" : "604146b3-2e0c-4399-826e-a18cbc18362b", "router_id" : { "Ref" : "heat_router_01" } } },
"heat_router_int0" : { "Type" : "OS::Neutron::RouterInterface", "Properties" : { "router_id" : { "Ref" : "heat_router_01" }, "subnet_id" : { "Ref" : "heat_subnet_01" } } },
"instance0_port0" : { "Type" : "OS::Neutron::Port", "Properties" : { "admin_state_up" : "True", "network_id" : { "Ref" : "heat_network_01" }, "security_groups" : ["b0ab35c3-63f0-48d2-8a6b-08364a026b9c"] } },
"instance1_port0" : { "Type" : "OS::Neutron::Port", "Properties" : { "admin_state_up" : "True", "network_id" : { "Ref" : "heat_network_01" }, "security_groups" : ["b0ab35c3-63f0-48d2-8a6b-08364a026b9c"] } },
"instance0" : { "Type" : "OS::Nova::Server", "Properties" : { "name" : "heat-instance-01", "image" : "73669ac0-8677-498d-9d97-76af287bcf32", "flavor": "m1.xsmall", "networks" : [{ "port" : { "Ref" : "instance0_port0" } }] } },
"instance1" : { "Type" : "OS::Nova::Server", "Properties" : { "name" : "heat-instance-02", "image" : "73669ac0-8677-498d-9d97-76af287bcf32", "flavor": "m1.xsmall", "networks" : [{ "port" : { "Ref" : "instance1_port0" } }] } } } } |
view rawheat-json-example.json hosted with ❤ by GitHub
下面咱们一块儿快速地过一下这个template。
若是你想使用JSON,那么我推荐你收藏一个JSON检查的网站,好比jsonlint.com
一旦你定义好Heat template,你可使用这个template经过Heat CLI或者dashboard来建立一个stack. 下面是个人一个stack在dashboard上的截图。
仍是不错的吧?你以为呢?我但愿这个Heat介绍对你有所帮助。我确实有计划想在最近介绍一个OpenStack Heat的其余方面,因此保持联系。若是有任何问题,更正,或者澄清,请不吝赐教。