OpenStack Victoria : Heat 利用方法2020/10/21 |
OpenStack Orchestration Service(Heat)の利用方法です。
当例では以下のような環境を例に Orchestration サービスを設定しています。
------------+---------------------------+---------------------------+------------ | | | 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] | 構築した Heat サービスとテンプレートを利用してインスタンスをデプロイします。 作業は、どこでもよいですが、当例ではコントロールノード上で行います。 |
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 }')
# サンプルテンプレートからインスタンス作成 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 | +---------------------+--------------------------------------+ # しばらく待つとステータスがコンプリートになる 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 | +--------------------------------------+--------------+----------------------------------+-----------------+----------------------+--------------+ # テンプレートで指定したインスタンスが起動している 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 | +--------------------------------------+----------------------+--------+-------------------------+------------+----------+ # 作成したインスタンスを削除する root@dlp ~(keystone)# openstack stack delete --yes Sample-Stack root@dlp ~(keystone)# openstack stack list |
[2] |
テンプレートの記述方法のガイドは公式サイトに記載されているので参考にしてください。
⇒ https://docs.openstack.org/heat/latest/template_guide/index.html |
[3] | 一般ユーザーでも Heat を利用したい場合は、設定変更が必要です。 |
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 | +----------------------------------+-----------------------------------------------------------------------+ # 例として [hiroshima] プロジェクトの [serverworld] ユーザーを [heat_stack_owner] ロールに追加 root@dlp ~(keystone)# openstack role add --project hiroshima --user serverworld heat_stack_owner
root@dlp ~(keystone)#
vi /etc/neutron/policy.json # 以下の内容で新規作成 # 管理者のみに許可されている権限を設定なしで上書きする { "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
# 以上で一般ユーザーでも以下のようにスタックが作成できる 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 | +--------------------------------------+--------------+-----------------+----------------------+--------------+ |
Sponsored Link |