CentOS Stream 8
Sponsored Link

OpenStack Wallaby : How to use Heat2021/04/23

 
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  |   |      Open vSwitch     |   |        Libvirt        |
|  Memcached  httpd     |   |     Neutron Server    |   |     Nova Compute      |
|  Keystone   Glance    |   |       OVN-Northd      |   |      Open vSwitch     |
|  Nova API             |   |     Cinder Volume     |   |   OVN Metadata Agent  |
|  Cinder API           |   |      iSCSI Target     |   |     OVN-Controller    |
|                       |   |     Heat API/Engine   |   |                       |
+-----------------------+   +-----------------------+   +-----------------------+

[1] Deploy Instances with Heat services and templates.
The example below is on the Controle Node.
# install Heat client with enabling Wallaby, EPEL, PowerTools

[root@dlp ~(keystone)]#
dnf --enablerepo=centos-openstack-wallaby,powertools,epel -y install python3-heatclient
# create a template for test

[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 |
+--------------------------------------+-----------------+--------+
| a7f1ad19-4d09-498c-8152-404bf626af98 | CentOS-Stream-8 | active |
+--------------------------------------+-----------------+--------+

[root@dlp ~(keystone)]#
openstack network list

+--------------------------------------+---------+--------------------------------------+
| ID                                   | Name    | Subnets                              |
+--------------------------------------+---------+--------------------------------------+
| 0538d835-a80f-4a32-a460-4c2001bebc49 | private | c7799645-dd7a-4347-b341-58f995d2f83e |
| 2cc12720-71da-4e48-810d-ec5306278a8b | public  | f9e1cbc7-0f73-4cae-960e-c3ca930d5ff6 |
+--------------------------------------+---------+--------------------------------------+

[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=CentOS-Stream-8;NetID=$Int_Net_ID" Sample-Stack

+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| id                  | 697b3f30-2540-42e0-804b-a40e2cc97d9b |
| stack_name          | Sample-Stack                         |
| description         | Heat Sample Template                 |
| creation_time       | 2021-04-23T07:25:02Z                 |
| updated_time        | None                                 |
| stack_status        | CREATE_IN_PROGRESS                   |
| stack_status_reason | Stack CREATE started                 |
+---------------------+--------------------------------------+

# turn to [CREATE_COMPLETE] after few minutes later

[root@dlp ~(keystone)]#
openstack stack list

+--------------------------------------+--------------+----------------------------------+-----------------+----------------------+--------------+
| ID                                   | Stack Name   | Project                          | Stack Status    | Creation Time        | Updated Time |
+--------------------------------------+--------------+----------------------------------+-----------------+----------------------+--------------+
| 697b3f30-2540-42e0-804b-a40e2cc97d9b | Sample-Stack | 5740dfa09acd480aaf87b406af946eaf | CREATE_COMPLETE | 2021-04-23T07:25:02Z | None         |
+--------------------------------------+--------------+----------------------------------+-----------------+----------------------+--------------+

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

[root@dlp ~(keystone)]#
openstack server list

+--------------------------------------+----------------------+--------+------------------------+-----------------+----------+
| ID                                   | Name                 | Status | Networks               | Image           | Flavor   |
+--------------------------------------+----------------------+--------+------------------------+-----------------+----------+
| c231f21e-76df-4cd9-86c3-5c0c6d8a9ae0 | Heat_Deployed_Server | ACTIVE | private=192.168.100.11 | CentOS-Stream-8 | m1.small |
+--------------------------------------+----------------------+--------+------------------------+-----------------+----------+

# delete the instance

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

[root@dlp ~(keystone)]#
openstack stack list
[root@dlp ~(keystone)]#
openstack server 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             |
+----------------------------------+------------------+
| 00086f6092d34919aa62973fa15d2bfc | reader           |
| 1dd8803e318a41d48d80737aa343d646 | heat_stack_user  |
| 81488bc28f1f4ed388e85fd0fad70553 | heat_stack_owner |
| 8bd67639f56c4d7a9496343f69486805 | member           |
| b46a0fc710c145beb34127f07ddb7e65 | CloudUser        |
| ef7fd41cc433450b942a69e91b01bb33 | admin            |
+----------------------------------+------------------+

[root@dlp ~(keystone)]#
openstack project list

+----------------------------------+-----------+
| ID                               | Name      |
+----------------------------------+-----------+
| 5740dfa09acd480aaf87b406af946eaf | admin     |
| 620c149e6cc84d7e8f446504cd3cd355 | service   |
| 9bdf6ca0e49a416da8df5554fbfdec74 | hiroshima |
+----------------------------------+-----------+

[root@dlp ~(keystone)]#
openstack user list

+----------------------------------+-------------------+
| ID                               | Name              |
+----------------------------------+-------------------+
| 55135c8c8605415f8c9a4b9453e6d71e | admin             |
| 1b81695cf7d54a8aa6feefa627f41089 | glance            |
| be4223a668704b2a88d151172ad31e23 | nova              |
| fcee296558f74da19339adfa8b162e4e | placement         |
| 66868daa68bf4eecab7a661717f0d50a | neutron           |
| b7aeb44b614d46f69b4a53ecee906800 | serverworld       |
| 9c936cba6ce54444b632c91565462c2c | cinder            |
| 15c6102e915e4956832c757880e15ae5 | heat              |
| 273c5fed816a499c983640fecabf5e4f | heat_domain_admin |
+----------------------------------+-------------------+

# 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

# on th Node Neutron Server is running, change settings for Neutron

[root@network ~]#
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@network ~]#
systemctl restart neutron-server

# that's OK, allowed common users can create stacks

[cent@dlp ~(keystone)]$
openstack stack list

+--------------------------------------+--------------+-----------------+----------------------+--------------+
| ID                                   | Stack Name   | Stack Status    | Creation Time        | Updated Time |
+--------------------------------------+--------------+-----------------+----------------------+--------------+
| 6235c9ad-6f7d-4736-8050-ff764219300e | Sample-Stack | CREATE_COMPLETE | 2021-04-23T07:30:04Z | None         |
+--------------------------------------+--------------+-----------------+----------------------+--------------+
[cent@dlp ~(keystone)]$
openstack server list

+--------------------------------------+----------------------+---------+------------------------------------+-----------------+----------+
| ID                                   | Name                 | Status  | Networks                           | Image           | Flavor   |
+--------------------------------------+----------------------+---------+------------------------------------+-----------------+----------+
| 5b944503-3702-461d-8160-0c08dbbb0665 | Heat_Deployed_Server | ACTIVE  | private=192.168.100.136            | CentOS-Stream-8 | m1.small |
+--------------------------------------+----------------------+---------+------------------------------------+-----------------+----------+
Matched Content