一:简介

    一、什么Heat

1. Heat 是一套业务流程平台,旨在帮助用户更轻松地配置以 OpenStack 为基础的云体系。利用Heat应用程序,开发人员能够在程序中使用模板以实现资源的自动化部署。Heat能够启动应用、创建虚拟机并自动处理整个流程。它还拥有出色的跨平台兼容性,能够与 Amazon Web Services 业务流程平台 CloudFormation 相对接——这意味着用户完全可以将 AWS 模板引入 OpenStack 环境当中。

2. Heat 是 OpenStack 提供的自动编排功能的组件,基于描述性的模板,来编排复合云应用程序。

    二、为什么需要Heat

1. 更快更有效的管理 OpenStack 的资源:云平台系统在相对比较稳定的情况下,管理成本逐渐变成首要的解决问题。云上自动化能力是一个云平台的刚需,可以有效降低维护难度。Heat 采用了模板方式来设计或者定义编排,为方便用户使用,Heat 还提供了大量的模板例子,使用户能够方便地得到想要的编排。

2. 更小的研发成本:引入 Heat,对于不了解 OpenStack 的研发者来说,可以更快的接入现有的业务系统。开发者更关心的是授权认证和对虚拟资源的增删改,而对于底层的状态并不用太多了解。

    三、概念

       1. 堆栈(stack):管理资源的集合。单个模板中定义的实例化资源的集合,是 Heat 管理应用程序的逻辑单元,往往对应一个应用程序。

2. 模板(template):如何使用代码定义和描述堆栈。描述了所有组件资源以及组件资源之间的关系,是 Heat 的核心。

3. 资源(resource):将在编排期间创建或修改的对象。资源可以是网络、路由器、子网、实例、卷、浮动IP、安全组等。

4. 参数(parameters):heat模板中的顶级key,定义在创建或更新 stack 时可以传递哪些数据来定制模板。

5. 参数组(parameter_groups):用于指定如何对输入参数进行分组,以及提供参数的顺序。

6. 输出(outputs):heat模板中的顶级key,定义实例化后 stack 将返回的数据。

二:架构

    一、核心架构

       

1. heat command-line client:CLI通过与 heat-api 通信,来调用 API 实现相关功能。终端开发者可以直接使用编排 REST API。

2. heat-api:实现 OpenStack 原生支持的 REST API。该组件通过把 API 请求经由 AMQP 传送给 Heat engine 来处理 API 请求。

3. heat-api-cfn:提供与 AWS CloudFormation 兼容的、AWS 风格的查询 API,处理请求并通过 AMQP 将它们发送到 heat-engine。

4. heat-engine:执行模板内容,最终完成应用系统的创建和部署,并把执行结果返回给 API 调用者。

5. heat-cfntools:完成虚拟机实例内部的操作配置任务,需要单独下载。

    二、工作流程

       1. 用户在 Horizon 中或者命令行中提交包含模板和参数输入的请求

2. Horizon 或者命令行工具会将接收到的请求转化为 REST 格式的 API 调用 Heat-api 或者是 Heat-api-cfn。

3. Heat-api 和 Heat-api-cfn 会验证模板的正确性,然后通过 AMQP 异步传递给 Heat Engine 来处理请求。

4. Heat Engine 接收到请求后,会把请求解析为各种类型的资源,每种资源都对应 OpenStack 其它的服务客户端,然后通过发送 REST 的请求给其它服务。

5. Heat Engine 在这里的作用分为三层: 第一层处理 Heat 层面的请求,就是根据模板和输入参数来创建 Stack,这里的 Stack 是由各种资源组合而成。 第二层解析 Stack 里各种资源的依赖关系,Stack 和嵌套 Stack 的关系。第三层就是根据解析出来的关系,依次调用各种服务客户段来创建各种资源。

三、模板

    一、 概念:Heat 模板全称为heat orchestration template,简称为HOT。

    二、模板详解

1. 典型 Heat 模板结构

 heat_template_version: --             ### HOT版本
description: ### 说明
# a description of the template parameter_groups: ### 指定参数顺序
- label: <human-readable label of parameter group>
description: <description of the parameter group>
parameters:
- <param name>
- <param name> parameters: ### 传递的参数
<param name>: ### 参数名
type: <string | number | json | comma_delimited_list | boolean> ### 参数类型
label: <human-readable name of the parameter> ### 标签
description: <description of the parameter>
default: <default value for parameter>
hidden: <true | false> ### 是否隐藏
constraints: ### 已有的内置参数:OS::stack_name、OS::stack_id、OS::project_id
<parameter constraints>
immutable: <true | false> resources: ### 资源对象
<resource ID>: ### 资源的ID
type: <resource type> ### 资源的类型
properties: ### 资源的属性
<property name>: <property value>
metadata: ### 资源的元数据
<resource specific metadata>
depends_on: <resource ID or list of ID>
update_policy: <update policy>
deletion_policy: <deletion policy> outputs: ### 返回值
<parameter name>: ### 参数名
description: <description> ### 说明
value: <parameter value> ### 输出值

2. 例子

 heat_temp_version:--
Description: AWS::CloudWatch::Alarm using Ceilometer.
parameters:
user_name:
type: string
label: User Name
description: User name to be configured for the application
port_number:
type: number
label: Port Number
description: Port number to be configured for the web server resources:
my_instance:
type: OS::Nova::Server
properties:
flavor: m1.small
image: F18-x86_64-cfntools outputs:
instance_ip:
description: IP address of the deployed compute instance
value: { get_attr: [my_instance, first_address] }

   

    三、模板内部函数

1. get_attr:获取所创建资源的属性

 语法
get_attr:
- <resource name> ### 必须是模板 resouce 段中指定的资源。
- <attribute name> ### 要获取的属性,如果属性对应的值是list 或map, 则可以指定key/index来获取具体的值。
- <key/index > (optional)
- <key/index > (optional)
- ... 示例
resources:
my_instance:
type: OS::Nova::Server
# ... outputs:
instance_ip:
description: IP address of the deployed compute instance
value: { get_attr: [my_instance, first_address] }
instance_private_ip:
description: Private IP address of the deployed compute instance
value: { get_attr: [my_instance, networks, private, ] }

2. get_file:获取文件的内容

 语法
get_file: <content key> 示例
resources:
my_instance:
type: OS::Nova::Server
properties:
# general properties ...
user_data:
get_file: my_instance_user_data.sh
my_other_instance:
type: OS::Nova::Server
properties:
# general properties ...
user_data:
get_file: http://example.com/my_other_instance_user_data.sh

3. get_param:引用模板中指定的参数

 语法
get_param:
- <parameter name>
- <key/index 1> (optional)
- <key/index 2> (optional)
- ... 示例
parameters:
instance_type:
type: string
label: Instance Type
description: Instance type to be used.
server_data:
type: json resources:
my_instance:
type: OS::Nova::Server
properties:
flavor: { get_param: instance_type}
metadata: { get_param: [ server_data, metadata ] }
key_name: { get_param: [ server_data, keys, 0 ] }
24
25 输出
   {"instance_type": "m1.tiny",
{"server_data": {"metadata": {"foo": "bar"},"keys": ["a_key","other_key"]}}}

4. get_resource:获取模板中指定的资源

 语法
get_resource: <resource ID> 示例
resources:
instance_port:
type: OS::Neutron::Port
properties: ... instance:
type: OS::Nova::Server
properties:
...
networks:
port: { get_resource: instance_port }

5. list_join:使用指定的分隔符将一个list中的字符串合成一个字符串

 语法
list_join:
- <delimiter>
- <list to join> 示例输出:one,two,three
list_join: [', ', ['one', 'two', 'and three']]

6. digest:在指定的值上使用algorithm

 语法
digest:
- <algorithm> ### 可用的值是hashlib(md5, sha1, sha224, sha256, sha384, and sha512) 或openssl的相关值
- <value> 示例
# from a user supplied parameter
pwd_hash: { digest: ['sha512', { get_param: raw_password }] }

7. repeat:迭代fore_each中的列表,按照template的格式生成一个list

 语法
repeat:
template:
<template>
for_each:
<var>: <list> 示例
parameters:
ports:
type: comma_delimited_list
label: ports
default: "80,443,8080"
protocols:
type: comma_delimited_list
label: protocols
default: "tcp,udp" resources:
security_group:
type: OS::Neutron::SecurityGroup
properties:
name: web_server_security_group
rules:
repeat:
for_each:
<%port%>: { get_param: ports }
<%protocol%>: { get_param: protocols }
template:
protocol: <%protocol%>
port_range_min: <%port%> 结果
[{‘protocal’:tpc, ‘prot_range_min’:}, {‘protocal’:tpc, ‘prot_range_min’:}, {‘protocal’:tpc, ‘prot_range_min’:}, {‘protocal’:udp, ‘prot_range_min’:}, {‘protocal’:udp, ‘prot_range_min’:}, {‘protocal’:udp, ‘prot_range_min’:}]

8. resource_facade:检索资源的数据

9. str_replace:使用params中的值替换template中的占位符,从而构造一个新的字符串

 语法
str_replace:
template: <template string>
params: <parameter mappings> 示例
resources:
my_instance:
type: OS::Nova::Server
# general metadata and properties ... outputs:
Login_URL:
description: The URL to log into the deployed application
value:
str_replace:
template: http://host/MyApplication
params:
host: { get_attr: [ my_instance, first_address ] }

10. str_split:将一个字符串按照分隔符分隔成一个list

 语法
str_split:
- ','
- string,to,split 示例
str_split: [',', 'string,to,split'] 结果
['string', 'to', 'split']

四:常用操作

    一、栈、资源、模板管理

          

    二、软件、快照管理

         

OpenStack的Heat组件详解的更多相关文章

  1. OpenStack的Swift组件详解

    一:简介     一.背景 1. Swift 最初是由 Rackspace 公司开发的高可用分布式对象存储服务(Object  Storage Service),并于 2010 年贡献给 OpenSt ...

  2. OpenStack的Trove组件详解

    一:简介     一.背景 1. 对于公有云计算平台来说,只有计算.网络与存储这三大服务往往是不太够的,在目前互联网应用百花齐放的背景下,几乎所有应用都使用到数据库,而数据库承载的往往是应用最核心的数 ...

  3. OpenStack 的Nova组件详解

    Open Stack Compute Infrastructure (Nova) Nova是OpenStack云中的计算组织控制器.支持OpenStack云中实例(instances)生命周期的所有活 ...

  4. OpenStack各组件详解和通信流程

    一.openstack由来 openstack最早由美国国家航空航天局NASA研发的Nova和Rackspace研发的swift组成.后来以apache许可证授权,旨在为公共及私有云平台建设.open ...

  5. Android中Intent组件详解

    Intent是不同组件之间相互通讯的纽带,封装了不同组件之间通讯的条件.Intent本身是定义为一个类别(Class),一个Intent对象表达一个目的(Goal)或期望(Expectation),叙 ...

  6. Android笔记——四大组件详解与总结

     android四大组件分别为activity.service.content provider.broadcast receiver. ------------------------------- ...

  7. vue.js基础知识篇(6):组件详解

    第11章:组件详解 组件是Vue.js最推崇也最强大的功能之一,核心目标是可重用性. 我们把组件代码按照template.style.script的拆分方式,放置到对应的.vue文件中. 1.注册 V ...

  8. Echars 6大公共组件详解

    Echars 六大组件详解 : title  tooltip toolbox legend  dataZoom visualMap 一.title标题详解 myTitleStyle = { color ...

  9. Angular6 学习笔记——组件详解之组件通讯

    angular6.x系列的学习笔记记录,仍在不断完善中,学习地址: https://www.angular.cn/guide/template-syntax http://www.ngfans.net ...

随机推荐

  1. Java本地的项目,怎么可以让别人通过外网访问-内网穿透

    2019独角兽企业重金招聘Python工程师标准>>> 一.点击链接 https://natapp.cn/ 注册个免费的账户 NATAPP官网 二.登陆进去以后查看authtoken ...

  2. CF--思维练习--CodeForces - 220C Little Elephant and Shifts (STL模拟)

    ACM思维题训练集合 The Little Elephant has two permutations a and b of length n, consisting of numbers from ...

  3. D. Count the Arrays 计数题

    D. Count the Arrays 也是一个计数题. 题目大意: 要求构造一个满足题意的数列. \(n\) 代表数列的长度 数列元素的范围 \([1,m]\) 数列必须有且仅有一对相同的数 存在一 ...

  4. 一阶RC低通滤波器详解(仿真+matlab+C语言实现)

    文章目录 1 预备知识 2 simulink 仿真 3 simulink 运行结果 4 matlab实现 5 matlab运行结果 6 C语言实现 7 C语言运行结果 如果本文帮到了你,帮忙点个赞: ...

  5. u-boot: Not enough room for program headers, try linking with -N

    在编译u-boot的时候出现了以下错误: arm-linux-gnueabi-ld.bfd: u-boot: Not enough room for program headers, try link ...

  6. Python语法学习第三天--元组

    元组:元组与列表相似,但是元组不能随意修改 ①创建元组 使用圆括号,用逗号隔开 空元组tuple1=()元组中只包含一个元素时,需要在元素后面添加逗号#逗号是关键tuple1=(1,) 当tuple1 ...

  7. [hdu1242]优先队列

    题意:给一个地图,'x'走一步代价为2,'.'走一步代价为1,求从s到t的最小代价.裸优先队列. #pragma comment(linker, "/STACK:10240000,10240 ...

  8. Mysql 常用函数(8)- concat 函数

    Mysql常用函数的汇总,可看下面系列文章 https://www.cnblogs.com/poloyy/category/1765164.html concat 的作用 连接多个字符串 concat ...

  9. C++内存管理学习笔记(3)

    /****************************************************************/ /*            学习是合作和分享式的! /* Auth ...

  10. 🏃‍♀️点亮你的Vue技术栈,万字Nuxt.js实践笔记来了~

    前言 作为一位 Vuer(vue开发者),如果还不会这个框架,那么你的 Vue 技术栈还没被点亮. Nuxt.js 是什么 Nuxt.js 官方介绍: Nuxt.js 是一个基于 Vue.js 的通用 ...