Orchestration 서비스는 stack 으로 서술하여 템플릿을 사용합니다. 템플릿 언어를 학습하기 위해서는 Heat developer documentation 에서 the Template Guide 를 확인하십시오.
demo-template.yml 파일을 다음 내용과 함께 생성합니다:
heat_template_version: 2015-10-15
description: Launch a basic instance with CirrOS image using the
``m1.tiny`` flavor, ``mykey`` key, and one network.
parameters:
NetID:
type: string
description: Network ID to use for the instance.
resources:
server:
type: OS::Nova::Server
properties:
image: cirros
flavor: m1.tiny
key_name: mykey
networks:
- network: { get_param: NetID }
outputs:
instance_name:
description: Name of the instance.
value: { get_attr: [ server, name ] }
instance_ip:
description: IP address of the instance.
value: { get_attr: [ server, first_address ] }
demo-template.yml 템플릿을 사용하여 스택을 생성합니다.
다음 단계를 관리자가 아닌 프로젝트로 수행하기 위해 demo credential을 소스로 가져옵니다:
$ . demo-openrc
사용 가능한 네트워크를 결정합니다.
$ openstack network list
+--------------------------------------+-------------+--------------------------------------+
| ID | Name | Subnets |
+--------------------------------------+-------------+--------------------------------------+
| 4716ddfe-6e60-40e7-b2a8-42e57bf3c31c | selfservice | 2112d5eb-f9d6-45fd-906e-7cabd38b7c7c |
| b5b6993c-ddf9-40e7-91d0-86806a42edb8 | provider | 310911f6-acf0-4a47-824e-3032916582ff |
+--------------------------------------+-------------+--------------------------------------+
주석
출력이 작업 환경과 다를 수 있습니다.
NET_ID 환경 변수를 네트워크에 대한 ID를 반영하도록 설정합니다. 예를 들면, 프로바이더 네트워크를 사용하는 경우:
$ export NET_ID=$(openstack network list | awk '/ provider / { print $2 }')
CirrOS 인스턴스 한 개에 대한 스택을 프로바이더 네트워크에 생성합니다:
$ openstack stack create -t demo-template.yml --parameter "NetID=$NET_ID" stack
+--------------------------------------+------------+--------------------+---------------------+--------------+
| ID | Stack Name | Stack Status | Creation Time | Updated Time |
+--------------------------------------+------------+--------------------+---------------------+--------------+
| dbf46d1b-0b97-4d45-a0b3-9662a1eb6cf3 | stack | CREATE_IN_PROGRESS | 2015-10-13T15:27:20 | None |
+--------------------------------------+------------+--------------------+---------------------+--------------+
잠시 후, 스택에 대한 생성 성공을 검증합니다:
$ openstack stack list
+--------------------------------------+------------+-----------------+---------------------+--------------+
| ID | Stack Name | Stack Status | Creation Time | Updated Time |
+--------------------------------------+------------+-----------------+---------------------+--------------+
| dbf46d1b-0b97-4d45-a0b3-9662a1eb6cf3 | stack | CREATE_COMPLETE | 2015-10-13T15:27:20 | None |
+--------------------------------------+------------+-----------------+---------------------+--------------+
인스턴스에 대한 이름과 IP 주소를 살펴보고 OpenStack 클라이언트에 대한 출력과 비교합니다:
$ openstack stack output show --all stack
[
{
"output_value": "stack-server-3nzfyfofu6d4",
"description": "Name of the instance.",
"output_key": "instance_name"
},
{
"output_value": "10.4.31.106",
"description": "IP address of the instance.",
"output_key": "instance_ip"
}
]
$ openstack server list
+--------------------------------------+---------------------------+--------+---------------------------------+
| ID | Name | Status | Networks |
+--------------------------------------+---------------------------+--------+---------------------------------+
| 0fc2af0c-ae79-4d22-8f36-9e860c257da5 | stack-server-3nzfyfofu6d4 | ACTIVE | public=10.4.31.106 |
+--------------------------------------+---------------------------+--------+---------------------------------+
스택을 삭제합니다.
$ openstack stack delete --yes stack
Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.