十二、Openstack编排服务(heat)
简单介绍:
heat主要有四个组件:heat-api、heat-engine、heat-api-cfn
heat-api:一个OpenStack本地 REST API ,发送API请求到heat-engine,通过远程过程调用(RPC)
heat-api-cfn:AWS 队列API,和AWS CloudFormation兼容,发送API请求到heat-engine,通过远程过程调用
heat-engine:启动模板和提供给API消费者回馈事件
控制节点上
mysql -uroot -p
CREATE DATABASE heat;
GRANT ALL PRIVILEGES ON heat.* TO 'heat'@'localhost' IDENTIFIED BY '123456';
GRANT ALL PRIVILEGES ON heat.* TO 'heat'@'%' IDENTIFIED BY '123456';
2.创建heat用户
需要管理员权限
. admin-openrc
openstack user create --domain default --password-prompt heat
[root@controller ~]# . admin-openrc
[root@controller ~]# openstack user create --domain default --password-prompt heat
User Password:
Repeat User Password:
+-----------+----------------------------------+
| Field | Value |
+-----------+----------------------------------+
| domain_id | b24b3093654b4ba4be706fe675a03b2d |
| enabled | True |
| id | 7237d6802d0142d498f70b26587cfd8a |
| name | heat |
+-----------+----------------------------------+
openstack role add --project service --user heat admin
此操作无返回
4.创建heat 和 heat-cfn 服务实体
heat
openstack service create --name heat --description "Orchestration" orchestration
[root@controller ~]# openstack service create --name heat --description "Orchestration" orchestration
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | Orchestration |
| enabled | True |
| id | ecbbbee759b6422c89c2b6eb6962133f |
| name | heat |
| type | orchestration |
+-------------+----------------------------------+
openstack service create --name heat-cfn --description "Orchestration" cloudformation
[root@controller ~]# openstack service create --name heat-cfn --description "Orchestration" cloudformation
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | Orchestration |
| enabled | True |
| id | 06b223ae69444ad6abc5a6c1c6a72993 |
| name | heat-cfn |
| type | cloudformation |
+-------------+----------------------------------+
5.创建 Orchestration 服务的 API 端点(括号前面有“ \ ”)
openstack endpoint create --region RegionOne orchestration public http://controller:8004/v1/%\ (tenant_id\ )s
openstack endpoint create --region RegionOne orchestration internal http://controller:8004/v1/%\ (tenant_id\ )s
openstack endpoint create --region RegionOne orchestration admin http://controller:8004/v1/%\ (tenant_id\ )s
[root@controller ~]# openstack endpoint create --region RegionOne orchestration public http://controller:8004/v1/%(tenant_id)s
+--------------+-----------------------------------------+
| Field | Value |
+--------------+-----------------------------------------+
| enabled | True |
| id | 009c1a976c3d4e33a75449b0473f9ccf |
| interface | public |
| region | RegionOne |
| region_id | RegionOne |
| service_id | ecbbbee759b6422c89c2b6eb6962133f |
| service_name | heat |
| service_type | orchestration |
| url | http://controller:8004/v1/%(tenant_id)s |
+--------------+-----------------------------------------+
[root@controller ~]# openstack endpoint create --region RegionOne orchestration internal http://controller:8004/v1/%(tenant_id)s
+--------------+-----------------------------------------+
| Field | Value |
+--------------+-----------------------------------------+
| enabled | True |
| id | a9faac32b5d04ca1a9af012a7ed862dc |
| interface | internal |
| region | RegionOne |
| region_id | RegionOne |
| service_id | ecbbbee759b6422c89c2b6eb6962133f |
| service_name | heat |
| service_type | orchestration |
| url | http://controller:8004/v1/%(tenant_id)s |
+--------------+-----------------------------------------+
[root@controller ~]# openstack endpoint create --region RegionOne orchestration admin http://controller:8004/v1/%(tenant_id)s
+--------------+-----------------------------------------+
| Field | Value |
+--------------+-----------------------------------------+
| enabled | True |
| id | 1851bbf86fb440f99341109c46a0160e |
| interface | admin |
| region | RegionOne |
| region_id | RegionOne |
| service_id | ecbbbee759b6422c89c2b6eb6962133f |
| service_name | heat |
| service_type | orchestration |
| url | http://controller:8004/v1/%(tenant_id)s |
+--------------+-----------------------------------------+
6.创建Cloudformation服务的 API 端点
openstack endpoint create --region RegionOne cloudformation public http://controller:8000/v1
openstack endpoint create --region RegionOne cloudformation internal http://controller:8000/v1
openstack endpoint create --region RegionOne cloudformation admin http://controller:8000/v1
[root@controller ~]# openstack endpoint create --region RegionOne cloudformation public http://controller:8000/v1
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | 4ab91aa026f048d09355b965363d4375 |
| interface | public |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 06b223ae69444ad6abc5a6c1c6a72993 |
| service_name | heat-cfn |
| service_type | cloudformation |
| url | http://controller:8000/v1 |
+--------------+----------------------------------+
[root@controller ~]# openstack endpoint create --region RegionOne cloudformation internal http://controller:8000/v1
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | 3642ae85f2754873b26d3a95ca0715df |
| interface | internal |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 06b223ae69444ad6abc5a6c1c6a72993 |
| service_name | heat-cfn |
| service_type | cloudformation |
| url | http://controller:8000/v1 |
+--------------+----------------------------------+
[root@controller ~]# openstack endpoint create --region RegionOne cloudformation admin http://controller:8000/v1
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | 70c68c28b41840c297904d9bbf3e4f50 |
| interface | admin |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 06b223ae69444ad6abc5a6c1c6a72993 |
| service_name | heat-cfn |
| service_type | cloudformation |
| url | http://controller:8000/v1 |
+--------------+----------------------------------+
7.为栈创建 heat 包含项目和用户的域
openstack domain create --description "Stack projects and users" heat
[root@controller ~]# openstack domain create --description "Stack projects and users" heat
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | Stack projects and users |
| enabled | True |
| id | 5a006439aef044bb83b8fd73ff6940e6 |
| name | heat |
+-------------+----------------------------------+
openstack user create --domain heat --password-prompt heat_domain_admin
[root@controller ~]# openstack user create --domain heat --password-prompt heat_domain_admin
User Password:
Repeat User Password:
+-----------+----------------------------------+
| Field | Value |
+-----------+----------------------------------+
| domain_id | 5a006439aef044bb83b8fd73ff6940e6 |
| enabled | True |
| id | 9bd2c8e158424e0aac407a65cb8088b0 |
| name | heat_domain_admin |
+-----------+----------------------------------+
9.添加admin角色到 heat 域 中的heat_domain_admin用户,启用heat_domain_admin用户管理栈的管理权限
openstack role add --domain heat --user-domain heat --user heat_domain_admin admin
此操作无返回
10.创建 heat_stack_owner 角色
openstack role create heat_stack_owner
[root@controller ~]# openstack role create heat_stack_owner
+-----------+----------------------------------+
| Field | Value |
+-----------+----------------------------------+
| domain_id | None |
| id | f17937c920924d23bae8d108275ed3ee |
| name | heat_stack_owner |
+-----------+----------------------------------+
11.添加heat_stack_owner 角色到demo项目和用户,启用demo 用户管理栈
openstack role add --project demo --user demo heat_stack_owner
此操作无返回
12.创建 heat_stack_user 角色
openstack role create heat_stack_user
[root@controller ~]# openstack role create heat_stack_user
+-----------+----------------------------------+
| Field | Value |
+-----------+----------------------------------+
| domain_id | None |
| id | b78f46c2d9ca4969b98346c92eb0bd23 |
| name | heat_stack_user |
+-----------+----------------------------------+
安装配置:
1.安装软件包
yum install openstack-heat-api openstack-heat-api-cfn openstack-heat-engine
yum install openstack-heat-api openstack-heat-api-cfn openstack-heat-engine
2.修改配置文件/etc/heat/heat.conf
vi /etc/heat/heat.conf
[DEFAULT]
rpc_backend = rabbit#启用消息队列
heat_metadata_server_url = http://controller:8000#配置元数据
heat_waitcondition_server_url = http://controller:8000/v1/waitcondition#配置URLserver
#配置栈域与管理凭据
stack_domain_admin = heat_domain_admin#具有足够管理用户和项目功能的用户
stack_domain_admin_password = 123456#(heat_domain_admin用户选择密码)
stack_user_domain_name = heat#包含heat的域
配置数据库访问
[database]
connection = mysql+pymysql://heat:123456@controller/heat
配置消息队列
[oslo_messaging_rabbit]
rabbit_host = controller
rabbit_userid = openstack
rabbit_password = 123456
配置认证服务访问(都是heat的密码)
[keystone_authtoken]#没有这个自己添加在配置文件最下面
auth_uri = http://controller:5000
auth_url = http://controller:35357
memcached_servers = controller:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = heat
password = 123456
[trustee]
auth_plugin = password#要加载的插件的名称
auth_url = http://controller:35357#认证的URL
username = heat#用户名
password = 123456#密码
user_domain_name = default#域
[clients_keystone]
auth_uri = http://controller:35357#没有版本的URL
[ec2authtoken]
auth_uri = http://controller:5000/v2.0#认证的端点的URI
3.同步Orchestration数据库
su -s /bin/sh -c "heat-manage db_sync" heat
[root@controller ~]# vi /etc/heat/heat.conf
[root@controller ~]# su -s /bin/sh -c "heat-manage db_sync" heat
2017-11-16 11:08:46.484 17785 INFO migrate.versioning.api [-] 27 -> 28...
2017-11-16 11:08:47.516 17785 INFO migrate.versioning.api [-] done
2017-11-16 11:08:47.516 17785 INFO migrate.versioning.api [-] 28 -> 29...
2017-11-16 11:08:47.724 17785 INFO migrate.versioning.api [-] done
2017-11-16 11:08:47.724 17785 INFO migrate.versioning.api [-] 29 -> 30...
2017-11-16 11:08:47.810 17785 INFO migrate.versioning.api [-] done
2017-11-16 11:08:47.811 17785 INFO migrate.versioning.api [-] 30 -> 31...
2017-11-16 11:08:47.907 17785 INFO migrate.versioning.api [-] done
...
...
...
2017-11-16 11:09:13.848 17785 INFO migrate.versioning.api [-] 68 -> 69...
2017-11-16 11:09:13.858 17785 INFO migrate.versioning.api [-] done
2017-11-16 11:09:13.858 17785 INFO migrate.versioning.api [-] 69 -> 70...
2017-11-16 11:09:13.870 17785 INFO migrate.versioning.api [-] done
2017-11-16 11:09:13.870 17785 INFO migrate.versioning.api [-] 70 -> 71...
2017-11-16 11:09:14.183 17785 INFO migrate.versioning.api [-] done
完成安装:
启动 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
[root@controller ~]# systemctl enable openstack-heat-api.service openstack-heat-api-cfn.service openstack-heat-engine.service
Created symlink from /etc/systemd/system/multi-user.target.wants/openstack-heat-api.service to /usr/lib/systemd/system/openstack-heat-api.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/openstack-heat-api-cfn.service to /usr/lib/systemd/system/openstack-heat-api-cfn.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/openstack-heat-engine.service to /usr/lib/systemd/system/openstack-heat-engine.service.
[root@controller ~]# systemctl start openstack-heat-api.service openstack-heat-api-cfn.service openstack-heat-engine.service
验证:
使用管理员权限
. admin-openrc
openstack orchestration service list
[root@controller ~]# . admin-openrc
[root@controller ~]# openstack orchestration service list
+------------+-------------+---------------------+------------+--------+---------------------+--------+
| hostname | binary | engine_id | host | topic | updated_at | status |
+------------+-------------+---------------------+------------+--------+---------------------+--------+
| controller | heat-engine | e1066999-feed-4b43 | controller | engine | 2017-11-16T16:25:34 | up |
| | | -a44a-60a8483c1b0a | | | .000000 | |
| controller | heat-engine | b9b6cf22-8321-4a9b- | controller | engine | 2017-11-16T16:25:34 | up |
| | | b9a6-892c1da4a2b8 | | | .000000 | |
| controller | heat-engine | b9aeb965-d292-486c- | controller | engine | 2017-11-16T16:25:20 | up |
| | | 977a-4bf185fb3882 | | | .000000 | |
| controller | heat-engine | 1fbf6581-ef7c-43ab- | controller | engine | 2017-11-16T16:25:20 | up |
| | | 80e4-a112e15345a4 | | | .000000 | |
+------------+-------------+---------------------+------------+--------+---------------------+--------+