Cloud Assembly テンプレートの設計では、マシンのクラスタを展開し、ディスクのクラスタを接続できます。
マシンおよびディスクのクラスタを展開するには、クラウド テンプレートで allocatePerInstance resource フラグ、count.index および map_to_object 式の構文を利用します。
次のクラウド テンプレート コードの例は、クラスタを展開する際の設計のガイドラインとして使用できます。
ディスク クラスタを共有する 2 台のマシン
resources:
app0:
type: Cloud.Machine
allocatePerInstance: true
properties:
image: ubuntu
flavor: small
attachedDisks: '${map_to_object(slice(resource.disk[*].id, 0,2), "source")}'
app1:
type: Cloud.Machine
allocatePerInstance: true
properties:
image: ubuntu
flavor: small
attachedDisks: '${map_to_object(slice(resource.disk[*].id, 2,4), "source")}'
disk:
type: Cloud.Volume
allocatePerInstance: true
properties:
count: 4
capacityGb: 5
それぞれ 1 つのディスクを持つマシンの台数(可変)
inputs:
count:
type: integer
default: 2
resources:
Cloud_Machine_1:
type: Cloud.Machine
allocatePerInstance: true
properties:
image: ubuntu
flavor: small
count: '${input.count}'
attachedDisks: '${map_to_object(slice(resource.disk[*].id, count.index, count.index + 1), "source")}'
disk:
type: Cloud.Volume
allocatePerInstance: true
properties:
count: '${input.count}'
capacityGb: 5
それぞれ 2 つのディスクを持つマシンの台数(可変)
inputs:
count:
type: integer
default: 2
resources:
Cloud_Machine_1:
type: Cloud.Machine
allocatePerInstance: true
properties:
image: ubuntu
flavor: small
count: ${input.count}
attachedDisks: '${map_to_object(slice(resource.disk[*].id, 2*count.index, 2*(count.index + 1)), "source")}'
disk:
type: Cloud.Volume
allocatePerInstance: true
properties:
count: ${2*input.count}
capacityGb: 5
要求時にディスク サイズを設定
inputs:
disksize:
type: array
minItems: 2
maxItems: 2
items:
type: object
properties:
size:
type: integer
resources:
app:
type: Cloud.Machine
allocatePerInstance: true
properties:
flavor: small
image: ubuntu
attachedDisks: ${map_to_object(slice(resource.disk[*].id, 0, 2), 'source')}
disk:
type: Cloud.Volume
allocatePerInstance: true
properties:
count: 2
capacityGb: ${input.disksize[count.index].size}