CentOS 8
Sponsored Link

OpenStack Victoria : How to use Heat2020/11/19

 
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     |   |        L2 Agent       |   |     Nova Compute      |
|  Keystone   Glance    |   |        L3 Agent       |   |      Open vSwitch     |
|  Nova API             |   |     Metadata Agent    |   |        L2 Agent       |
|  Neutron Server       |   |     Cinder Volume     |   |                       |
|  Metadata Agent       |   |   Heat API   API-CFN  |   |                       |
|  Cinder API           |   |   Heat Engine         |   |                       |
+-----------------------+   +-----------------------+   +-----------------------+

[1] Deploy Instances with Heat services and templates. The example below is on the Controle Node.
# 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 |
+--------------------------------------+---------+--------+
| 8507b98f-3e9d-4ac9-92f9-9ee8d7f69339 | CentOS8 | active |
+--------------------------------------+---------+--------+

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

+--------------------------------------+---------+--------------------------------------+
| ID                                   | Name    | Subnets                              |
+--------------------------------------+---------+--------------------------------------+
| 8a3e03ec-41a8-487c-8d43-fbffee4a4461 | private | 7127bc8a-ff8b-4f37-9434-76797539f47f |
| fff92352-d109-4a98-a6e4-d56c6cbac5b0 | public  | 781dce3f-0bd1-4d17-9f4f-c0962639ecb6 |
+--------------------------------------+---------+--------------------------------------+

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

+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| id                  | 5c9f1244-0ce7-443a-8a93-a6185dc9e149 |
| stack_name          | Sample-Stack                         |
| description         | Heat Sample Template                 |
| creation_time       | 2020-11-19T07:26:14Z                 |
| 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 |
+--------------------------------------+--------------+----------------------------------+-----------------+----------------------+--------------+
| 5c9f1244-0ce7-443a-8a93-a6185dc9e149 | Sample-Stack | bd0827a1282f45f28c4100b77289eb0a | CREATE_COMPLETE | 2020-11-19T07:26:14Z | None         |
+--------------------------------------+--------------+----------------------------------+-----------------+----------------------+--------------+

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

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

+--------------------------------------+----------------------+--------+-------------------------+---------+----------+
| ID                                   | Name                 | Status | Networks                | Image   | Flavor   |
+--------------------------------------+----------------------+--------+-------------------------+---------+----------+
| c5461650-0943-4c17-96ce-0cd11e998152 | Heat_Deployed_Server | ACTIVE | private=192.168.100.161 | CentOS8 | 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
Matched Content