ARTICLE · INTELLIGENCE

战地情报 · 详情页

来自尧图项目组的一线实战观察与深度解析

OpenStack编排管理-heat

OpenStack编排管理-heat OpenStack编排管理-heat文章目录OpenStack编排管理-heatheat作用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-engineHeat的核心主要实现任务调度、资源生命周期管理等作用自身并不提供资源创建功 能只负责编排资源后交由其他组件去处理。#查看heat相关进程[rootcontroller ~]# 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相关服务[rootcontroller ~]# 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.txtheat_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/24ip_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创建完成
RELATED READING

延伸阅读

更多一线实战笔记与深度复盘,助您持续精进