在CentOS7.0安装Orchestration模块(heat)

作者:【吴业亮】云计算开发工程师
博客:http://blog.csdn.net/wylfengyujiancheng
一、Orchestration模块概念
1、Orchestration模块提供了一个基于模板的orchestration,用于描述云的应用,通过运行的OpenStack API调用生成运行的云应用。软件和OpenStack其他核心组件集成为一个单一文件的模板系统。模板允许用户创建大多数的OpenStack资源类型,诸如实例,floating IP,卷,安全组,用户等,它也提供高级功能,诸如实例高可用,实例自动扩展,以及嵌套的OpenStack,这给OpenStack的核心项目带来了大量的用户基础。
2、Orchestration模块通常包含下面的组件:
heat 命令行客户端一个命令行工具,和heat-api通信,以运行AWS CloudFormation API,最终开发者可以直接使用Orchestration REST API。
heat-api 组件一个OpenStack本地 REST API ,发送API请求到heat-engine,通过远程过程调用(RPC)。
heat-api-cfn 组件AWS 队列API,和AWS CloudFormation兼容,发送API请求到heatengine,通过远程过程调用。
heat-engine 启动模板和提供给API消费者回馈事件。
二、安装和配置
1、创建heat数据库
a.登陆数据库,并输入数据库密码

mysql -u root -p

b.创建 heat 数据库

CREATE DATABASE heat;

c.为 heat 数据库赋予合适的访问权限:

GRANT ALL PRIVILEGES ON heat.* TO 'heat'@'localhost' \ IDENTIFIED BY 'HEAT_DBPASS';
GRANT ALL PRIVILEGES ON heat.* TO 'heat'@'%' \ IDENTIFIED BY 'HEAT_DBPASS';

注意将`HEAT_DBPASS替换为自己的密码
d.退出数据库

exit

截图

2、导入 admin 身份凭证以执行管理员用户专有的命令:

source admin-openrc.sh
  1. 创建服务证书,完成如下步骤:
    a. 创建heat用户:
openstack user create --password-prompt heat
User Password:
Repeat User Password: +----------+----------------------------------+
| Field | Value | +----------+----------------------------------+
| email    | None                             |
| enabled  | True                             |
| id       | 4a8ba242ba3e4ae8a0de4c0ed2fa74a7 |
| name     | heat                             |
| username | heat | +----------+----------------------------------+

b. 为heat用户添加admin角色:

openstack role add --project service --user heat admin +-------+----------------------------------+
| Field | Value | +-------+----------------------------------+
| id    | 51b3e606b8cc42bd9c43da4af07b3d08 |
| name | admin | +-------+----------------------------------+

c. 创建heat_stack_owner角色:

 openstack role create heat_stack_owner +-------+----------------------------------+
| Field | Value | +-------+----------------------------------+
| id    | 0ac8bcc58fa04c58b9aa5f0b3ca74373 |
| name | heat_stack_owner | +-------+----------------------------------+

d. 为 demo 租户和用户添加 heat_stack_owner 角色:

openstack role add --project demo --user demo heat_stack_owner +-------+----------------------------------+
| Field | Value | +-------+----------------------------------+
| id    | 0ac8bcc58fa04c58b9aa5f0b3ca74373 |
| name | heat_stack_owner | +-------+----------------------------------+

e. 创建 heat_stack_user 角色:

openstack role create heat_stack_user +-------+----------------------------------+
| Field | Value | +-------+----------------------------------+
| id    | 902a007b7864445984ebd210d3c67dd8 |
| name | heat_stack_user | +-------+----------------------------------+

f. 创建 heat 和 heat-cfn 服务实体:

# openstack service create --name heat \
> --description "Orchestration" orchestration +-------------+----------------------------------+
| Field | Value | +-------------+----------------------------------+
| description | Orchestration                    |
| enabled     | True                             |
| id          | d0ec49a7d6ef4797bbe722ed2f2cd70a |
| name        | heat                             |
| type | orchestration | +-------------+----------------------------------+
# openstack service create --name heat-cfn \
> --description "Orchestration" cloudformation +-------------+----------------------------------+
| Field | Value | +-------------+----------------------------------+
| description | Orchestration                    |
| enabled     | True                             |
| id          | f0f6085173294693a167d54fd8eb8235 |
| name        | heat-cfn                         |
| type | cloudformation | +-------------+----------------------------------+

4.创建 Orchestration 服务的 API 端点:

# openstack endpoint create \
> --publicurl http://controller:8004/v1/%\(tenant_id\)s \
> --internalurl http://controller:8004/v1/%\(tenant_id\)s \
> --adminurl http://controller:8004/v1/%\(tenant_id\)s \
> --region RegionOne \
> orchestration
+--------------+-----------------------------------------+
| Field | Value |
+--------------+-----------------------------------------+
| adminurl | http://controller:8004/v1/%(tenant_id)s |
| id | 64e04221026a4d95a06a2ee42eb66d65 |
| internalurl | http://controller:8004/v1/%(tenant_id)s |
| publicurl | http://controller:8004/v1/%(tenant_id)s |
| region | RegionOne |
| service_id | d0ec49a7d6ef4797bbe722ed2f2cd70a |
| service_name | heat |
| service_type | orchestration |
+--------------+-----------------------------------------+
# openstack endpoint create \
> --publicurl http://controller:8000/v1 \
> --internalurl http://controller:8000/v1 \
> --adminurl http://controller:8000/v1 \
> --region RegionOne \
> cloudformation +--------------+----------------------------------+
| Field | Value | +--------------+----------------------------------+
| adminurl     | http://controller:8000/v1        |
| id           | 90fc9a132f484e249f8ae339e99a1eef |
| internalurl  | http://controller:8000/v1        |
| publicurl    | http://controller:8000/v1        |
| region       | RegionOne                        |
| service_id | f0f6085173294693a167d54fd8eb8235 | | service_name | heat-cfn                         |
| service_type | cloudformation | +--------------+----------------------------------+

三、安装和配置Orchestration组件
1. 运行以下命令安装软件包:

# yum install openstack-heat-api openstack-heat-api-cfn openstack-heat-engine python-heatclient -y

2.修改配置文件 /etc/heat/heat.conf 并完成以下操作
a. 在 [database] 段,配置数据库访问相关参数

[database]
connection = mysql://heat:HEAT_DBPASS@controller/heat

注意:将其中的 HEAT_DBPASS 替换为您为 Orchestration 数据库所设置的密码。
b. 在 [DEFAULT] 和 [oslo_messaging_rabbit] 段,对 RabbitMQ 消息代理相关参数进行配置:

[DEFAULT]
rpc_backend = rabbit
[oslo_messaging_rabbit]
rabbit_host = controller
rabbit_userid = openstack
rabbit_password = RABBIT_PASS

注意:将 RABBIT_PASS 替换为 RabbitMQ 服务中 openstack 用户的密码。
c. 在 [keystone_authtoken] 和 [ec2authtoken] 部分中,配置身份认证服务的访问:

[keystone_authtoken]
auth_uri = http://controller:5000/v2.0
identity_uri = http://controller:35357
admin_tenant_name = service
admin_user = heat
admin_password = HEAT_PASS
[ec2authtoken]
auth_uri = http://controller:5000/v2.0

注意:将其中的 HEAT_PASS 替换为您在身份认证服务中为 heat 用户设置的密码。
d. 在 [DEFAULT] 部分,配置 metadata 和等待环境 URLs:

[DEFAULT]
heat_metadata_server_url = http://controller:8000
heat_waitcondition_server_url = http://controller:8000/v1/waitcondition

e. 在 [DEFAULT] 部分,配置heat认证服务域

[DEFAULT]
stack_domain_admin = heat_domain_admin
stack_domain_admin_password = HEAT_DOMAIN_PASS
stack_user_domain_name = heat_user_domain

替换HEAT_DOMAIN_PASS为上面设置的密码
f.(可选配置)可以在 [DEFAULT] 段中开启详细日志配置,为后期的故障排除提供帮
助:

[DEFAULT]
verbose = True

3.执行环境变量

source admin-openrc.sh

创建heat实体服务

heat-keystone-setup-domain \
--stack-user-domain-name heat_user_domain \
--stack-domain-admin heat_domain_admin \
--stack-domain-admin-password HEAT_DOMAIN_PASS

注意:替换HEAT_DOMAIN_PASS用个合适的密码

4、同步Orchestration数据库:

# su -s /bin/sh -c "heat-manage db_sync" heat

5、 启动 Orchestration 服务并将其设置为随系统启动

# systemctl enable openstack-heat-api.service openstack-heat-api-cfn.service openstack-heat-engine.service
# systemctl start openstack-heat-api.service openstack-heat-api-cfn.service openstack-heat-engine.service

三、 验证操作
a.执行环境变量

# source admin-openrc.sh

b.创建test-stack.yml

heat_template_version: 2014-10-16
description: A simple server.
parameters:
    ImageID:
        type: string
        description: Image use to boot a server
    NetID:
        type: string
        description: Network ID for the server
resources:
    server:
        type: OS::Nova::Server
        properties:
            image: { get_param: ImageID }
            flavor: m1.tiny
            networks:
            - network: { get_param: NetID }
outputs:
    private_ip:
        description: IP address of the server in the private network
        value: { get_attr: [ server, first_address ] }

c. 使用heat stack-create命令行以模板创建一个栈:

# NET_ID=$(nova net-list | awk '/ demo-net / { print $2 }')
# heat stack-create -f test-stack.yml \
-P "ImageID=cirros-0.3.4-x86_64;NetID=$NET_ID" testStack

d.使用heat stack-list命令行来验证栈的创建是否成功:

# heat stack-list

界面显示:

在CentOS7.0安装Orchestration模块(heat)_第1张图片
本博客主要参考:
http://docs.openstack.org/kilo

你可能感兴趣的:(centos,openstack,kilo,Heat,Orchestrat)