执行范围
仅控制节点(controller / 11.0.1.30)
Heat 提供基础设施编排能力,通过 HOT(Heat Orchestration Template)模板批量创建 Nova、Neutron 等资源。
source /etc/keystone/admin-openrc.sh1. 创建数据库
mysql -uroot -p000000 -e "CREATE DATABASE heat;"mysql -uroot -p000000 -e "GRANT ALL PRIVILEGES ON heat.* TO 'heat'@'%' IDENTIFIED BY '000000';"mysql -uroot -p000000 -e "GRANT ALL PRIVILEGES ON heat.* TO 'heat'@'localhost' IDENTIFIED BY '000000';"2. 注册 Keystone 用户与服务
openstack user create --domain default --password 000000 heatopenstack role add --project service --user heat admin
openstack service create --name heat --description "Orchestration" orchestrationopenstack service create --name heat-cfn --description "Orchestration" cloudformation
openstack endpoint create --region RegionOne orchestration public http://controller:8004/v1/%\(tenant_id\)sopenstack endpoint create --region RegionOne orchestration internal http://controller:8004/v1/%\(tenant_id\)sopenstack endpoint create --region RegionOne orchestration admin http://controller:8004/v1/%\(tenant_id\)sopenstack endpoint create --region RegionOne cloudformation public http://controller:8000/v1openstack endpoint create --region RegionOne cloudformation internal http://controller:8000/v1openstack endpoint create --region RegionOne cloudformation admin http://controller:8000/v13. 创建 Heat 专用域与用户
openstack domain create --description "Stack projects and users" heatopenstack user create --domain heat --password 000000 heat_domain_adminopenstack role add --domain heat --user-domain heat --user heat_domain_admin adminopenstack role create heat_stack_owneropenstack role add --project demo --user demo heat_stack_owneropenstack role create heat_stack_user4. 安装软件包
yum install -y openstack-heat-api openstack-heat-api-cfn openstack-heat-engine openstack-heat-ui5. 配置 /etc/heat/heat.conf
crudini --set /etc/heat/heat.conf database connection mysql+pymysql://heat:000000@controller/heatcrudini --set /etc/heat/heat.conf DEFAULT transport_url rabbit://openstack:000000@controllercrudini --set /etc/heat/heat.conf DEFAULT heat_metadata_server_url http://controller:8000crudini --set /etc/heat/heat.conf DEFAULT heat_waitcondition_server_url http://controller:8000/v1/waitconditioncrudini --set /etc/heat/heat.conf DEFAULT stack_domain_admin heat_domain_admincrudini --set /etc/heat/heat.conf DEFAULT stack_domain_admin_password 000000crudini --set /etc/heat/heat.conf DEFAULT stack_user_domain_name heat
crudini --set /etc/heat/heat.conf keystone_authtoken auth_uri http://controller:5000crudini --set /etc/heat/heat.conf keystone_authtoken auth_url http://controller:5000crudini --set /etc/heat/heat.conf keystone_authtoken memcached_servers controller:11211crudini --set /etc/heat/heat.conf keystone_authtoken auth_type passwordcrudini --set /etc/heat/heat.conf keystone_authtoken project_domain_name defaultcrudini --set /etc/heat/heat.conf keystone_authtoken user_domain_name defaultcrudini --set /etc/heat/heat.conf keystone_authtoken project_name servicecrudini --set /etc/heat/heat.conf keystone_authtoken username heatcrudini --set /etc/heat/heat.conf keystone_authtoken password 000000
crudini --set /etc/heat/heat.conf trustee auth_type passwordcrudini --set /etc/heat/heat.conf trustee auth_url http://controller:5000crudini --set /etc/heat/heat.conf trustee username heatcrudini --set /etc/heat/heat.conf trustee password 000000crudini --set /etc/heat/heat.conf trustee user_domain_name defaultcrudini --set /etc/heat/heat.conf clients_keystone auth_uri http://controller:50006. 同步数据库并启动
su -s /bin/sh -c "heat-manage db_sync" heat
systemctl enable openstack-heat-api openstack-heat-api-cfn openstack-heat-enginesystemctl restart openstack-heat-api openstack-heat-api-cfn openstack-heat-enginesystemctl restart httpd memcached7. 验收
source /etc/keystone/admin-openrc.shsystemctl is-active openstack-heat-api openstack-heat-api-cfn openstack-heat-engineopenstack service list | grep heatopenstack stack list8. 示例 HOT 模板
创建 /root/demo-template.yml:
heat_template_version: 2018-08-31parameters: NetID: type: string description: Network ID to use for the instance. ImageID: type: string description: Image ID to use for the instance.resources: server: type: OS::Nova::Server properties: flavor: m1.tiny networks: - network: { get_param: NetID } image: { get_param: ImageID }outputs: instance_name: description: Name of the instance. value: { get_attr: [ server, name ] } instance_ip: description: IP address of the instance. value: { get_attr: [ server, first_address ] }使用 demo 用户创建栈:
source /etc/keystone/demo-openrc.shopenstack stack create -t /root/demo-template.yml \ --parameter NetID=<private网络ID> \ --parameter ImageID=<cirros镜像ID> \ demo-stackopenstack stack listopenstack stack show demo-stack