OpenStack编排管理-heat
文章目录
- OpenStack编排管理-heat
- heat作用
- heat与其他服务之间的关系
- heat架构
- heat组件
- heat engine架构
- heat模板
- Heat模板默认编写语言-YAML语法
- heat模板结构
- heat web实验
heat作用
Heat是一种通过OpenStack原生REST API使用声明性模板格式编排复合云应用程序的服务,提供与其他 OpenStack核心项目的紧密集成 Heat模板以文本文件的形式描述了云应用程序的基础架构,文本文件可供用户读写,并且支持通过 版本控制工具进行管理 Heat模板指定资源之间的关系,使得Heat能够调用OpenStack API以正确的顺序创建用户所需的基 础架构,从而完全启动用户的应用程序
heat与其他服务之间的关系
- Heat是位于Nova、Neutron等服务之上的一个组件,它充当了OpenStack对外接口的角色,用户不需 要直接接触OpenStack其他服务,只需把对各种资源的需求写在Heat模版里,Heat就会自动调用相关服 务的接口来配置资源,从而满足用户的需求。
heat架构
- 用户在Horizon中或者命令行中提交包含模板和参数输入的请求,Horizon或者命令行工具会把请求转化 为REST格式的API调用,然后调用Heat-api或者是Heat-api-cfn。Heat-api 和Heat-api-cfn会验证模板的 正确性,然后通过消息队列传递给Heat Engine来处理请求。 •Heat中的模板是OpenStack资源的集合(虚拟机、网络、存储、告警、浮动IP、安全组、伸缩组、嵌套 stack等),通过定义模板,可以将需要创建的资源在模板中描述,用此模板可以多次创建需要的资源。
heat组件
- Heat-api:提供REST API服务,是其他组件与Heat交互的入口,接收API请求并传送给heat-engine。 •Heat-api-cfn:提供兼容AWS CloudFormation的API,接收API请求并转发给heat-engine。 •Heat-engine:Heat的核心,主要实现任务调度、资源生命周期管理等作用,自身并不提供资源创建功 能,只负责编排资源后交由其他组件去处理。
#查看heat相关进程[root@controller ~]# ps -e | grep heat1721? 00:00:02 heat-api-cfn1722? 00:00:02 heat-api1776? 00:00:08 heat-engine2717? 00:00:00 heat-api-cfn2722? 00:00:00 heat-api-cfn2728? 00:00:00 heat-api-cfn2730? 00:00:00 heat-api-cfn2751? 00:00:00 heat-api2752? 00:00:00 heat-api2754? 00:00:00 heat-api2756? 00:00:00 heat-api3048? 00:00:00 heat-engine3056? 00:00:00 heat-engine3057? 00:00:00 heat-engine3059? 00:00:00 heat-engine#查看heat相关服务[root@controller ~]# systemctl status openstack-heat-*heat engine架构
heat模板
Heat模板默认编写语言-YAML语法
YAML Ain’t Markup Language 使用缩进(一个或多个空格)排版 序列项用短划线表示 MAP中的key-value对用冒号表示
heat模板结构
heat web实验
前期工作:
创建网络
查看刚才创建的网络
记录public_net id:
创建image
记录image id
编写hot模板 把下面这段写到heat.txt文件中 heat.txt
heat_template_version:2018-08-31 description: Simple template to deploy a stack with one virtual machine instances parameters: image_name_1: type: string label: Image ID description: SCOIMAGE Specify an image nameforinstance1 default: 732c9cee-2652-4a4e-8c09-19745d6e15b5#替换自己的image idpublic_net: type: string label: Network ID description: SCONETWORK Network to be usedforthe compute instance default: a6e27f03-e762-4c46-a997-a7a6848d5849#替换自己的外网 idresources: mykey: type: OS::Nova::KeyPair properties: save_private_key:truename: mykey web_secgroup: type: OS::Neutron::SecurityGroup properties: rules: - protocol: tcp remote_ip_prefix:0.0.0.0/0 port_range_min:22port_range_max:22- protocol: icmp private_net: type: OS::Neutron::Net properties: name: private_net private_subnet: type: OS::Neutron::Subnet properties: network_id:{get_resource: private_net}cidr:"192.168.99.0/24"ip_version:4vrouter: type: OS::Neutron::Router properties: external_gateway_info: network:{get_param: public_net}vrouter_interface: type: OS::Neutron::RouterInterface properties: router_id:{get_resource: vrouter}subnet_id:{get_resource: private_subnet}instance_port: type: OS::Neutron::Port properties: network:{get_resource: private_net}security_groups: - default -{get_resource: web_secgroup}fixed_ips: - subnet_id:{get_resource: private_subnet}floating_ip: type: OS::Neutron::FloatingIP properties: floating_network_id:{get_param: public_net}association: type: OS::Neutron::FloatingIPAssociation properties: floatingip_id:{get_resource: floating_ip}port_id:{get_resource: instance_port}instance1: type: OS::Nova::Server properties: image:{get_param: image_name_1}key_name:{get_resource: mykey}flavor: Flavor_web#替换自己创建的flavor名字networks: - port:{get_resource:instance_port}outputs: private_key: description: Private key value:{get_attr:[mykey, private_key]}创建堆栈:
选择heat.txt
创建完成