Ubuntu 20.04
Sponsored Link

OpenStack Victoria : How to use Heat2020/10/21

 
How to use the OpenStack Orchestration Service (Heat).
This example is based on the environment like follows.
------------+---------------------------+---------------------------+------------
            |                           |                           |
        eth0|10.0.0.30              eth0|10.0.0.50              eth0|10.0.0.51
+-----------+-----------+   +-----------+-----------+   +-----------+-----------+
|    [ Control Node ]   |   |    [ Network Node ]   |   |    [ Compute Node ]   |
|                       |   |                       |   |                       |
|  MariaDB    RabbitMQ  |   |        L2 Agent       |   |        Libvirt        |
|  Memcached  httpd     |   |        L3 Agent       |   |     Nova Compute      |
|  Keystone   Glance    |   |     Metadata Agent    |   |        L2 Agent       |
|  Nova API             |   |     Cinder Volume     |   |                       |
|  Neutron Server       |   |       Heat API        |   |                       |
|  Metadata Agent       |   |      Heat Engine      |   |                       |
|  Cinder API           |   |                       |   |                       |
+-----------------------+   +-----------------------+   +-----------------------+

[1] Deploy Instances with Heat services and templates. The example below is on the Controle Node.
# create a template for tests

root@dlp ~(keystone)#
vi sample-stack.yml
heat_template_version: 2018-08-31

description: Heat Sample Template

parameters:
  ImageID:
    type: string
    description: Image used to boot a server
  NetID:
    type: string
    description: Network ID for the server

resources:
  server1:
    type: OS::Nova::Server
    properties:
      name: "Heat_Deployed_Server"
      image: { get_param: ImageID }
      flavor: "m1.small"
      networks:
      - network: { get_param: NetID }

outputs:
  server1_private_ip:
    description: IP address of the server in the private network
    value: { get_attr: [ server1, first_address ] }

root@dlp ~(keystone)#
openstack image list

+--------------------------------------+------------+--------+
| ID                                   | Name       | Status |
+--------------------------------------+------------+--------+
| 7ba71e53-e270-4d2a-bbe9-0d642a6c019c | Ubuntu2004 | active |
+--------------------------------------+------------+--------+

root@dlp ~(keystone)#
openstack network list

+--------------------------------------+---------+--------------------------------------+
| ID                                   | Name    | Subnets                              |
+--------------------------------------+---------+--------------------------------------+
| 5d7b1b73-602d-40e2-a82f-352991de37e0 | public  | 7aa5fca7-efe4-4a30-b1f0-0653cc743a1c |
| 9f39959f-2f70-400c-aa80-5de54e92cf27 | private | e7e82cb2-29c0-4eea-a459-e212a2bc3650 |
+--------------------------------------+---------+--------------------------------------+

root@dlp ~(keystone)#
Int_Net_ID=$(openstack network list | grep private | awk '{ print $2 }')
# create an instance from the template

root@dlp ~(keystone)#
openstack stack create -t sample-stack.yml --parameter "ImageID=Ubuntu2004;NetID=$Int_Net_ID" Sample-Stack

+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| id                  | 78e6d355-1878-4759-89b7-24a28ced3fcc |
| stack_name          | Sample-Stack                         |
| description         | Heat Sample Template                 |
| creation_time       | 2020-10-21T05:19:12Z                 |
| updated_time        | None                                 |
| stack_status        | CREATE_IN_PROGRESS                   |
| stack_status_reason | Stack CREATE started                 |
+---------------------+--------------------------------------+

# turn to [CREATE_COMPLETE] after few minutes later like follows

root@dlp ~(keystone)#
openstack stack list

+--------------------------------------+--------------+----------------------------------+-----------------+----------------------+--------------+
| ID                                   | Stack Name   | Project                          | Stack Status    | Creation Time        | Updated Time |
+--------------------------------------+--------------+----------------------------------+-----------------+----------------------+--------------+
| 78e6d355-1878-4759-89b7-24a28ced3fcc | Sample-Stack | b573c9e160864f028fc2d681a929f5af | CREATE_COMPLETE | 2020-10-21T05:19:12Z | None         |
+--------------------------------------+--------------+----------------------------------+-----------------+----------------------+--------------+

# the instance is running which is created from the Heat template

root@dlp ~(keystone)#
openstack server list

+--------------------------------------+----------------------+--------+-------------------------+------------+----------+
| ID                                   | Name                 | Status | Networks                | Image      | Flavor   |
+--------------------------------------+----------------------+--------+-------------------------+------------+----------+
| 1aca5698-c52c-43ed-9101-664a2d114e96 | Heat_Deployed_Server | ACTIVE | private=192.168.100.244 | Ubuntu2004 | m1.small |
+--------------------------------------+----------------------+--------+-------------------------+------------+----------+

# delete the instance

root@dlp ~(keystone)#
openstack stack delete --yes Sample-Stack

root@dlp ~(keystone)#
openstack stack list


[2]
The guide for writing templates are opened on the official site below.
⇒ https://docs.openstack.org/heat/latest/template_guide/index.html
[3] If you'd like to use Heat with common users, it needs to change some settings.
root@dlp ~(keystone)#
openstack role list

+----------------------------------+------------------+
| ID                               | Name             |
+----------------------------------+------------------+
| 1838ec90094c480bae0979228a321c88 | heat_stack_user  |
| 5528fea7004044cfbd06ba1c2684af43 | CloudUser        |
| 624a27603cdf44a78fa802bf59a2ff8c | member           |
| 7e0d807bb67e4c239349385a85113bef | heat_stack_owner |
| 8cd056a250054dddb2a15853e0a7f441 | admin            |
| f24b4181288a42669c42e24405c92374 | reader           |
+----------------------------------+------------------+

root@dlp ~(keystone)#
openstack project list

+----------------------------------+-----------+
| ID                               | Name      |
+----------------------------------+-----------+
| 37197271a1954ddb90207a95d5f46488 | service   |
| 6c44eafd4f614985bf74b94f2aee82fb | hiroshima |
| b573c9e160864f028fc2d681a929f5af | admin     |
+----------------------------------+-----------+

root@dlp ~(keystone)#
openstack user list

+----------------------------------+-----------------------------------------------------------------------+
| ID                               | Name                                                                  |
+----------------------------------+-----------------------------------------------------------------------+
| ddcdc9a445bd45e7bdb71244343e7f78 | admin                                                                 |
| 03d8beaafa3045d58c3417bfec3bcefa | glance                                                                |
| d605621cc0f44bdcb93864d3347b2300 | nova                                                                  |
| 319fe43139464ecbb178e217253929f1 | placement                                                             |
| 2eadb99a37544406bc01b71eb7fb1b1c | neutron                                                               |
| a13cfae0e5eb466fae71a636a6ffb6b4 | serverworld                                                           |
| fd14a5e3cd654faba1b1e7923d298711 | cinder                                                                |
| 740a0d7b450c4949a6ea7af78c8f8565 | heat                                                                  |
| 147869d311494a9cb06c3a67f219541e | heat_domain_admin                                                     |
| 2473f94fed154b5290df73ed4e62763b | barbican                                                              |
| 42282050760e440392b589d313577658 | gnocchi                                                               |
| a954b69f9b8345d9a797abbc0a949108 | ceilometer                                                            |
| 08052d6e306c4ec7986996e31df01729 | magnum                                                                |
| c9bf3b2582274d47ba6629e157e9cc0b | magnum_domain_admin                                                   |
| b5c5dee78291406780b4d8fcb1fdfe5b | fc3358a4-1cac-470e-8db1-70b6c64c35c6_b573c9e160864f028fc2d681a929f5af |
+----------------------------------+-----------------------------------------------------------------------+

# for example, add [serverworld] user in [hiroshima] project to [heat_stack_owner] role

root@dlp ~(keystone)#
openstack role add --project hiroshima --user serverworld heat_stack_owner
root@dlp ~(keystone)#
vi /etc/neutron/policy.json
# create new

# overwrite some settings

{
  "create_port:fixed_ips:subnet_id": "",
  "create_port:allowed_address_pairs": "",
  "create_port:allowed_address_pairs:ip_address": "",
}

root@dlp ~(keystone)#
systemctl restart neutron-server

# that's OK, common users can create stacks

ubuntu@dlp ~(keystone)$
openstack stack list

+--------------------------------------+--------------+-----------------+----------------------+--------------+
| ID                                   | Stack Name   | Stack Status    | Creation Time        | Updated Time |
+--------------------------------------+--------------+-----------------+----------------------+--------------+
| 27d0d895-3bdd-4878-b5fa-0457f1db10df | Sample-Stack | CREATE_COMPLETE | 2020-10-24T09:05:11Z | None         |
+--------------------------------------+--------------+-----------------+----------------------+--------------+
Matched Content