CentOS Stream 8
Sponsored Link

OpenStack Xena : How to use Heat2021/11/24

 
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 from Xena, EPEL, PowerTools

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

[root@dlp ~(keystone)]#
vi sample-stack.yml
heat_template_version: 2021-04-16

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 |
+--------------------------------------+-----------------+--------+
| cfce605e-151b-43dd-b743-2c7988d69e96 | CentOS-Stream-8 | active |
+--------------------------------------+-----------------+--------+

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

+--------------------------------------+---------+--------------------------------------+
| ID                                   | Name    | Subnets                              |
+--------------------------------------+---------+--------------------------------------+
| 3adf0a70-6446-4095-916d-17d9f753bbe6 | private | 9724f8a3-4c59-4d7d-9838-82bc682a551c |
| ac8911e7-afd7-4913-997e-2f0412f1271b | public  | 61bf3654-bef1-4ddd-8d23-f2fd41166f4e |
+--------------------------------------+---------+--------------------------------------+

[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                  | 79d1f2bc-d154-4819-85ce-6a56e7df7105 |
| stack_name          | Sample-Stack                         |
| description         | Heat Sample Template                 |
| creation_time       | 2021-11-24T04:23:03Z                 |
| 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 |
+--------------------------------------+--------------+----------------------------------+-----------------+----------------------+--------------+
| 79d1f2bc-d154-4819-85ce-6a56e7df7105 | Sample-Stack | b12f95625664420ca31949963b75b74f | CREATE_COMPLETE | 2021-11-24T04:23:03Z | None         |
+--------------------------------------+--------------+----------------------------------+-----------------+----------------------+--------------+

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

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

+--------------------------------------+----------------------+--------+-------------------------+-----------------+----------+
| ID                                   | Name                 | Status | Networks                | Image           | Flavor   |
+--------------------------------------+----------------------+--------+-------------------------+-----------------+----------+
| 4f2cc892-1289-4692-b0d0-4571fc80aa0e | Heat_Deployed_Server | ACTIVE | private=192.168.100.179 | 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             |
+----------------------------------+------------------+
| 18965750e793496289f2adaae0c32dfe | heat_stack_owner |
| 2485ff2e98724284a466103b722de47c | reader           |
| 337ff970af864d6e9eafe2afca9b57b0 | CloudUser        |
| 7445e68099c44fc98d7569fec6730c2c | admin            |
| 813db945b1f843b69f06f3a0db335f09 | member           |
| df5f831d57bf4b3cb40922aa4a64713e | heat_stack_user  |
+----------------------------------+------------------+

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

+----------------------------------+-----------+
| ID                               | Name      |
+----------------------------------+-----------+
| 2decda8bcd724687a1cf05064ab21fdf | hiroshima |
| 7e53ef14eb894f379ea1929f5defc949 | service   |
| b12f95625664420ca31949963b75b74f | admin     |
+----------------------------------+-----------+

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

+----------------------------------+-------------------+
| ID                               | Name              |
+----------------------------------+-------------------+
| ca311dd55c7f4494bf3fa651ed0737ee | admin             |
| a6aba3ec75ff4c12ac4813f3324642c4 | glance            |
| fc1c665468b047b2b23426401c8ee604 | nova              |
| 2a4ab705034f47c5bfb2c762f3a696d3 | placement         |
| c6b1d6a496da49ca868d3e13541a42ed | neutron           |
| 6a517543654044e8b4ea9e0eea0adaa4 | serverworld       |
| c408ef15d8c3431dbbffd3099199f4d0 | cinder            |
| 211165f4c3b3488b87047219303997ae | heat              |
| e1aafd9236684afab49beed259f2d337 | 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 |
+--------------------------------------+--------------+-----------------+----------------------+--------------+
| 43845e3e-42c9-41f2-9e67-02313212ca32 | Sample-Stack | CREATE_COMPLETE | 2021-11-24T04:27:22Z | None         |
+--------------------------------------+--------------+-----------------+----------------------+--------------+
[cent@dlp ~(keystone)]$
openstack server list

+--------------------------------------+----------------------+---------+-------------------------------------+-----------------+----------+
| ID                                   | Name                 | Status  | Networks                            | Image           | Flavor   |
+--------------------------------------+----------------------+---------+-------------------------------------+-----------------+----------+
| 626ed011-2914-43c5-b6bf-e49ff5eacd4c | Heat_Deployed_Server | ACTIVE  | private=192.168.100.53              | CentOS-Stream-8 | m1.small |
| a6180855-77cf-476f-9f26-4fc79baa38c2 | CentOS-St-8          | SHUTOFF | private=10.0.0.250, 192.168.100.108 | CentOS-Stream-8 | m1.small |
+--------------------------------------+----------------------+---------+-------------------------------------+-----------------+----------+
Matched Content