Heat是 OpenStack 提供的自动编排功能的组件,基于描述性的模板,来编排复合云应用程序。Heat 采用了模板方式来设计或者定义编排,为方便用户使用,Heat 还提供了大量的模板例子,使用户能够方便地得到想要的编排
heat_template_version: 2014-10-16 resources: nova_flavor: type: OS::Nova::Flavor properties: name: m1.flavor disk: 20 is_public: True ram: 1024 vcpus: 2 flavorid: 1234
创建Net
编写Heat模板create_net.yaml,创建名为Heat-Network网络,选择不共享;
创建子网名为Heat-Subnet,子网网段设置为10.20.2.0/24,开启DHCP服务,地址池为10.20.2.20-10.20.2.100heat_template_version: 2014-10-16 resources: network_1: type: OS::Neutron::Net properties: admin_state_up: true name: Heat-Network shared: false subnet_1: type: OS::Neutron::Subnet properties: allocation_pools: - end: 10.20.2.100 start: 10.20.2.10 cidr: 10.20.2.0/24 enable_dhcp: true host_routes: [] name: Heat-Subnet network_id: get_resource: network_1
创建volume
编写Heat模板create_volume.yaml,大小为10G
heat_template_version: 2014-10-16 resources: my_new_volume: type: OS::Cinder::Volume properties: size: 10
创建server
编写Heat模板create_server.yaml,镜像为cirros,网络为extnet
heat_template_version: 2013-05-23 description: Test Template resources: myserver: type: OS::Nova::Server properties: name: "Test Heat server" image: { get_param: Image } flavor: "2" networks: - network: { get_param: Net } parameters: Image: type: string description: Image use to boot a server default: Net: type: string description: Network ID for the server default: outputs: myserver_private_ip: description: IP address of the server in the private network value: { get_attr: [ myserver, first_address ] } # heat stack-create -f create_server.yaml -P Image=cirros -P Net=extnet myserver