kokou Agbedanou
Service d’orchestration Heat
Heat est le service d’orchestration d’OpenStack. Il a pour but de fournir un service d’automate pour
effectuer des actions : provisionning de nouvelles instances en cas de pic de charge d’une instance par
exemple.
Les actions suivantes sont à effectuer sur le Controller node.
1. Création de la base de données heat
Comme pour les autres services, il faut créer la base heat dans MySQL.
#mysql -u root -p
MariaDB [(none)]> CREATE DATABASE heat;
GRANT ALL PRIVILEGES ON heat.* TO 'heatUser'@'localhost'
IDENTIFIED BY 'HEAT_DBPASS';
GRANT ALL PRIVILEGES ON heat.* TO 'heatUser'@'%' IDENTIFIED BY
'heatPass';
Remplacez heatPass par le vrai mot de passe.
2. Gestion des credentials
© Editions ENI - Tous droits réservés - Copie personnelle de kokou Agbedanou -1-
kokou Agbedanou
# source ~/admin_creds.sh
3. Création de l’utilisateur heatUser dans la base Keystone
# keystone user-create --name heatUser --pass heatPass
+ ----------+----------------------------------+
| Property | Value |
+ ----------+----------------------------------+
| email | |
| enabled | True |
| id | 7d29a7d4eac048dda5f75edecae0e608 |
| name | heatUser |
| username | heatUser |
+ ----------+----------------------------------+
4. Ajout du rôle admin et du tenant service pour l’utilisateur
heatUser
# keystone user-role-add --user heatUser --tenant service --role
admin
5. Création du rôle heat_stack_owner
© Editions ENI - Tous droits réservés - Copie personnelle de kokou Agbedanou -2-
kokou Agbedanou
Un rôle particulier est nécessaire (heat_stack_owner) si l’utilisateur admin souhaite déléguer la gestion
des stacks déployées par Heat.
# keystone role-create --name heat_stack_owner
+ ----------+----------------------------------+
| Property | Value |
+ ----------+----------------------------------+
| id | 77706edc3f504afaac546625b58a278c |
| name | heat_stack_owner |
+ ----------+----------------------------------+
6. Ajout du rôle heat_stack_owner au tenant demo et à l’utilisateur
demo
Dans cet exemple, c’est l’utilisateur demo qui va gérer la stack Heat :
# keystone user-role-add --user demo --tenant demo --role
heat_stack_owner
7. Création du rôle heat_stack_user
Lorsqu’un utilisateur effectue un déploiement de stack Heat, il se voit attribuer le rôle de heat_stack_user.
Il faut donc créer ce rôle :
# keystone role-create --name heat_stack_user
+ ----------+----------------------------------+
| Property | Value |
© Editions ENI - Tous droits réservés - Copie personnelle de kokou Agbedanou -3-
kokou Agbedanou
+ ----------+----------------------------------+
| id | 8287fc57a4904d8cb2d89794638369b5 |
| name | heat_stack_user |
+ ----------+----------------------------------+
8. Création des services d’entités (heat et heat-cfn)
Deux types de services sont nécessaires : le service d’orchestration et le service de cloud-formation.
# keystone service-create --name heat --type orchestration
--description "Orchestration"
+ -------------+----------------------------------+
| Property | Value |
+ -------------+----------------------------------+
| description | Orchestration |
| enabled | True |
| id | 0a000fb4cc8d488c861950901d7aa1a0 |
| name | heat |
| type | orchestration |
+ -------------+----------------------------------+
# keystone service-create --name heat-cfn --type cloudformation
--description "Orchestration"
+ -------------+----------------------------------+
| Property | Value |
+ -------------+----------------------------------+
| description | Orchestration |
| enabled | True |
| id | bd9646f8862d4859b649c47b7c71aa7d |
| name | heat-cfn |
© Editions ENI - Tous droits réservés - Copie personnelle de kokou Agbedanou -4-
kokou Agbedanou
| type | cloudformation |
+-------------+----------------------------------+
9. Création des services API endpoints
# keystone endpoint-create --service-id $(keystone service-list |
awk '/ orchestration / {print $2}') --publicurl http://srv-
openstack-controller:8004/v1/%\(tenant_id\)s --internalurl
http://srv-openstack-controller:8004/v1/%\(tenant_id\)s --adminurl
http://srv-openstack-controller:8004/v1/%\(tenant_id\)s --region
regionOne
+-------------+-------------------------------------------------------+
| Property | Value |
+-------------+-------------------------------------------------------+
| adminurl | http://srv-openstack-controller:8004/v1/%(tenant_id)s |
| id | 5 ab64e05b5134e1b89a7677116dbe676 |
| internalurl | http://srv-openstack-controller:8004/v1/%(tenant_id)s |
| publicurl | http://srv-openstack-controller:8004/v1/%(tenant_id)s |
| region | regionOne |
| service_id | 0 a000fb4cc8d488c861950901d7aa1a0 |
+-------------+-------------------------------------------------------+
Le port 8004 est le port utilisé par Heat.
# keystone endpoint-create --service-id $(keystone service-list |
awk '/ cloudformation / {print $2}') --publicurl http://srv-
openstack-controller:8000/v1 --internalurl http://srv-openstack-
controller:8000/v1 --adminurl http://srv-openstack-
controller:8000/v1 --region regionOne
+-------------+-----------------------------------------+
| Property | Value |
© Editions ENI - Tous droits réservés - Copie personnelle de kokou Agbedanou -5-
kokou Agbedanou
+-------------+-----------------------------------------+
| adminurl | http://srv-openstack-controller:8000/v1 |
| id | ceda466df0d241d2b8f55996cf8fb498 |
| internalurl | http://srv-openstack-controller:8000/v1 |
| publicurl | http://srv-openstack-controller:8000/v1 |
| region | regionOne |
| service_id | bd9646f8862d4859b649c47b7c71aa7d |
+-------------+----------------------------------------+
Le port 8000 est le port utilisé par Heat-cloudformation.
10. Installation et configuration des composants d’orchestration
Installation des paquets Heat
# yum install openstack-heat-api openstack-heat-api-cfn
openstack-heat-engine python-heatclient
Modification du fichier /etc/heat/heat.conf
[DEFAULT]
...
Verbose = True
rpc_backend = rabbit
rabbit_host = srv-openstack-controller
rabbit_password = RABBIT_PASS
heat_metadata_server_url = http://srv-openstack-controller:8000
heat_waitcondition_server_url = http://srv-openstack-
controller:8000/v1/waitcondition
© Editions ENI - Tous droits réservés - Copie personnelle de kokou Agbedanou -6-
kokou Agbedanou
[database]
...
connection = mysql://heatUser:heatPass@srv-openstack-
controller/heat
[keystone_authtoken]
...
auth_uri = http://srv-openstack-controller:5000/v2.0
identity_uri = http://srv-openstack-controller:35357
admin_tenant_name = service
admin_user = heatUser
admin_password = heatPass
[ec2authtoken]
...
auth_uri = http://srv-openstack-controller:5000/v2.0
Remplacez RABBIT_PASS et heatPass par les vrais mots de passe.
Peuplement de la base de données Heat
# su -s /bin/sh -c "heat-manage db_sync" heat
Cette commande crée les tables MySQL de la base heat sur le Controller node.
Opérations post-installation
# systemctl enable openstack-heat-api.service openstack-heat-api-
© Editions ENI - Tous droits réservés - Copie personnelle de kokou Agbedanou -7-
kokou Agbedanou
cfn.service openstack-heat-engine.service
# systemctl start openstack-heat-api.service openstack-heat-api-
cfn.service openstack-heat-engine.service
Test de l’installation
Ensuite, il faut créer un fichier template au format YAML contenant les informations pour déployer une
stack Heat à base des éléments suivants : une instance à partir de l’image cirros-0.3.3-x86_64 avec un
flavor m1.tiny et une adresse IP privée obtenue dans le range du subnet int-net (ce subnet a été créé au
préalable dans le chapitre Installation OpenStack : services de base - section Gestion des réseaux
virtuels).
#vi /etc/heat/templates
Création d'un template de test test-stack.yml
Heat_template_version: 2013-05-23
description: Test Template
# paramètres en entrée pour instancier le template
parameters:
ImageID:
type: string
description: Image use to boot a server
NetID:
type: string
description: Network ID for the server
# déclaration des ressources du template
resources:
server1:
type: OS::Nova::Server
properties:
name: "Test server"
image: { get_param: ImageID }
flavor: "m1.tiny"
networks:
- network: { get_param: NetID }
© Editions ENI - Tous droits réservés - Copie personnelle de kokou Agbedanou -8-
kokou Agbedanou
# paramètres de sortie disponibles pour l'utilisateur
outputs:
server1_private_ip:
description: IP address of the server in the private network
value: { get_attr: [ server1, first_address ] }
Gestion des credentials de l’utilisateur demo
Il faut au préalable sourcer les credentials du tenant demo.
# su demo
$ source ~/demo_creds.sh
Récupération d’une adresse réseau dans int-net
$ NET_ID=$(nova net-list | awk '/ int-net / { print $2 }')
# echo $NET_ID
5 ed881ff-77fe-4276-9c8b-b9fb0657d5d4
La commande nova net-listretourne le résultat suivant :
# nova net-list
+ --------------------------------------+---------+------+
| ID | Label | CIDR |
+ --------------------------------------+---------+------+
| 5ed881ff-77fe-4276-9c8b-b9fb0657d5d4 | int-net | None |
| 8935ce5f-2011-4f8d-8586-4bbd1ff98a2f | ext-net | None |
+ --------------------------------------+---------+------+
© Editions ENI - Tous droits réservés - Copie personnelle de kokou Agbedanou -9-
kokou Agbedanou
Déploiement de la stack teststack
$ heat stack-create -f test-stack.yml -P "ImageID=cirros-0.3.3-
x86_64;NetID=$NET_ID" testStack
+ --------------------------------------+------------+-----------
---------+----------------------+
| id | stack_name |
stack_status | creation_time |
+ --------------------------------------+------------+-----------
---------+----------------------+
| 40116b63-4f0f-469b-a433-fe4bb43efabe | testStack |
CREATE_IN_PROGRESS | 2015-06-24T20:27:52Z |
+ --------------------------------------+------------+-----------
---------+----------------------+
Vérification de fonctionnement
# heat stack-list
+ --------------------------------------+------------+--------------
+ ---------------+------------------------+
| id | stack_name |
stack_status | creation_time |
+ --------------------------------------+------------+--------------
+ ---------------+------------------------+
| 40116b63-4f0f-469b-a433-fe4bb43efabe | testStack |
CREATE_COMPLETE | 2015-06-24T 20:27:52Z |
+ --------------------------------------+------------+--------------
+ ---------------+------------------------+
© Editions ENI - Tous droits réservés - Copie personnelle de kokou Agbedanou - 10 -