マニフェストを表示する

各デプロイは、それぞれ対応するマニフェストを持ちます。マニフェストとは、デプロイ内のすべてのリソースを記述する読み取り専用のプロパティのことで、新しいデプロイごとに自動的に作成されます。作成されたマニフェストは変更できません。マニフェストは構成ファイルとは異なり、構成ファイルに基づいて作成されます。

始める前に

マニフェストの構造

マニフェストは、デプロイに関する次の 3 つの情報を示します。

  • 初期構成
  • テンプレートやインポートをすべて展開した後の完全評価版の構成
  • デプロイメントのすべてのリソースを階層構造で記述したデプロイメントのレイアウト

元の構成

元の構成とは、ユーザーがデプロイに提供した構成のことで、テンプレートを展開する前のものです。初期構成は config プロパティで示されます。

config: |
  imports:
  - path: vm-template.jinja
  - path: network-template.jinja
  - path: firewall-template.jinja
  - path: compute-engine-template.jinja

  resources:
  - name: compute-engine-setup
    type: compute-engine-template.jinja

展開済み構成

展開済み構成はデプロイメントを完全に記述したもので、すべてのテンプレートが処理されると、リソースとそのプロパティがすべて含まれます。これが構成の最終状態になります。

マニフェスト内の展開済み構成の部分は、expandedConfig プロパティで示されます。

expandedConfig: |
  resources:
  - name: datadisk-example-config-with-templates
    properties:
      sizeGb: 100
      type: https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/diskTypes/pd-standard
      zone: us-central1-a
    type: compute.v1.disk
  - name: vm-example-config-with-templates
    properties:
      disks:
      - autoDelete: true
        boot: true
        deviceName: boot
        initializeParams:
          diskName: disk-example-config-with-templates
          sourceImage: https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/debian-7-wheezy-v20140619
        type: PERSISTENT
      - autoDelete: true
        deviceName: datadisk-example-config-with-templates
        source: $(ref.datadisk-example-config-with-templates.selfLink)
        type: PERSISTENT
      machineType: https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/machineTypes/f1-micro
      metadata:
        items:
        - key: startup-script
          value: |
            #!/bin/bash
            python -m http.server 8080
      networkInterfaces:
      - accessConfigs:
        - name: External NAT
          type: ONE_TO_ONE_NAT
        network: https://www.googleapis.com/compute/v1/projects/myproject/global/networks/default
      zone: us-central1-a
    type: compute.v1.instance

インポートされたテンプレート

マニフェストの imports プロパティは、構成に対してインポートされたテンプレートのコンテンツを示します。マニフェストのインポート セクションは、imports セクションで示されます。

imports:
- content: |
    resources:
    - name: {{ env["name"] }}
      type: compute.v1.instance
      properties:
        disks:
        - autoDelete: true
          type: PERSISTENT
          boot: true
          deviceName: boot
          initializeParams:
            sourceImage:  https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/debian-7-wheezy-v20140619
        machineType: https://www.googleapis.com/compute/v1/projects/{{ env["project"] }}/zones/{{ properties["zone"] }}/machineTypes/{{ properties["machineType"] }}
        networkInterfaces:
        - network: $(ref.{{ properties["network"] }}.selfLink)
          accessConfigs:
          - name: External NAT
            type: ONE_TO_ONE_NAT
        zone: {{ properties["zone"] }}
        metadata:
          items:
          - key: startup-script
            value: |
              #!/bin/bash
              INSTANCE=$(curl http://metadata.google.internal/computeMetadata/v1/instance/hostname -H "Metadata-Flavor: Google")
              echo "<html><header><title>Hello from Deployment Manager!</title></header>
              <body><h2>Hello from $INSTANCE</h2>
              <p>Deployment Manager bids you good day!</p>
              </body>
              </html>" > index.html
              python -m http.server 80
  name: vm-template.jinja
- content: |
    resources:
    - name: {{ env["name"] }}
      type: compute.v1.network
      properties:
        IPv4Range: 10.0.0.1/16
  name: network-template.jinja
- content: |
    resources:
    - name: {{ env["name"]}}
      type: compute.v1.firewall
      properties:
        network: $(ref.{{ properties["network"] }}.selfLink)
        sourceRanges: ["0.0.0.0/0"]
        allowed:
        - IPProtocol: TCP
          ports: ["80"]
  name: firewall-template.jinja
- content: |
    {% set  NETWORK_NAME = "a-new-network" %}

    resources:
    - name: the-first-vm
      type: vm-template.jinja
      properties:
        machineType: f1-micro
        zone: us-central1-f
        network: {{ NETWORK_NAME }}
    - name: the-second-vm
      type: vm-template.jinja
      properties:
        machineType: g1-small
        zone: us-central1-f
        network: {{ NETWORK_NAME }}
    - name: {{ NETWORK_NAME }}
      type: network-template.jinja
    - name: {{ NETWORK_NAME }}-firewall
      type: firewall-template.jinja
      properties:
        network: {{ NETWORK_NAME }}
  name: compute-engine-template.jinja

レイアウト

レイアウトはデプロイメントとそのリソースの概要を表し、リソース名とタイプが表示されます。

レイアウトを使用することで、デプロイメントの構造が可視化され、構成を展開する前に、初期デプロイ時に設定されるテンプレート プロパティなど、構成に関するさまざまな情報を表示できます。

マニフェストでは、layout プロパティでレイアウトを確認できます。

layout: |
  resources:
  - name: compute-engine-setup
    resources:
    - name: the-first-vm
      properties:
        machineType: f1-micro
        network: a-new-network
        zone: us-central1-f
      resources:
      - name: the-first-vm
        type: compute.v1.instance
      type: vm-template.jinja
    - name: the-second-vm
      properties:
        machineType: g1-small
        network: a-new-network
        zone: us-central1-f
      resources:
      - name: the-second-vm
        type: compute.v1.instance
      type: vm-template.jinja
    - name: a-new-network
      resources:
      - name: a-new-network
        type: compute.v1.network
      type: network-template.jinja
    - name: a-new-network-firewall
      properties:
        network: a-new-network
      resources:
      - name: a-new-network-firewall
        type: compute.v1.firewall
      type: firewall-template.jinja
    type: compute-engine-template.jinja

マニフェストを識別する

マニフェストは、manifest-TIMESTAMP 形式で固有の ID で識別できます。次に例を示します。例:

manifest-1436393348324

マニフェスト ID を取得するには通常、該当デプロイメントの情報を取得するか、デプロイメントのマニフェストをリスト表示します。

gcloud

Google Cloud CLI で、次のように deployments describe サブコマンドを使用します。

gcloud deployment-manager deployments describe example-deployment

gcloud によって次のようなレスポンスが返されます。

id: '7428522736135856060'
manifest: https://www.googleapis.com/deploymentmanager/v2beta1/projects/myproject/global/deployments/example-deployment/manifests/manifest-1436393348324
name: example-deployment
resources:
NAME    TYPE      ID     STATE   ERRORS
...

API

API で、GET リクエストを作成し、リクエストにデプロイ名を指定します。

GET https://www.googleapis.com/deploymentmanager/v2beta1/projects/myproject/global/deployments/example-deployment-with-config

次のようなレスポンスが返されます。

{
 "id": "5899501332770090517",
 "creationTimestamp": "2015-03-30T15:40:58.809-07:00",
 "name": "example-deployment-with-config",
 "fingerprint": "",
 "manifest": "https://www.googleapis.com/deploymentmanager/v2/projects/myproject/global/deployments/example-deployment-with-config/manifests/manifest-1427755258810-2b3498d9-530b-4f8e-b014-0342d3c9c66b",
 "state": "DEPLOYED"
}

マニフェストを表示する

マニフェストを表示するには、Manifest リソースに対する get() リクエストを行うか、Google Cloud Console または gcloud を使用します。

Console

Google Cloud コンソールを使ってデプロイのマニフェストを表示するには:

  1. Google Cloud コンソールの [デプロイメント] ページに移動します。
  2. リストで、表示するデプロイをクリックします。
  3. デプロイの詳細で、[概要] をクリックします。

gcloud

Google Cloud CLI で、manifests describe コマンドを使用してマニフェスト全体を表示します。このコマンドは、マニフェストすべてとレイアウトの両方を表示します。

gcloud deployment-manager manifests describe manifest-1436393348324 \
    --deployment example-config-with-templates

gcloud によって次のようなレスポンスが返されます。

 config: |
   imports: ["vm_template.jinja"]

resources:

  • name: vm-instance type: vm_template.jinja properties: zone: us-central1-a project: myproject creationTimestamp: '2015-03-30T15:40:58.815-07:00' evaluatedConfig: | resources:
  • name: datadisk-example-config-with-templates properties: sizeGb: 100 type: https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/diskTypes/pd-standard zone: us-central1-a type: compute.v1.disk
  • name: vm-example-config-with-templates properties: disks:
    • autoDelete: true boot: true deviceName: boot initializeParams: diskName: disk-example-config-with-templates sourceImage: https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/debian-7-wheezy-v20140619 type: PERSISTENT
    • autoDelete: true deviceName: datadisk-example-config-with-templates source: $(ref.datadisk-example-config-with-templates.selfLink) type: PERSISTENT machineType: https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/machineTypes/f1-micro metadata: items:
      • key: startup-script value: | #!/bin/bash python -m http.server 8080 networkInterfaces:
    • accessConfigs:
      • name: External NAT type: ONE_TO_ONE_NAT network: https://www.googleapis.com/compute/v1/projects/myproject/global/networks/default zone: us-central1-a type: compute.v1.instance id: '7174699452487462421' layout: | resources:
  • name: vm-instance type: vm_template.jinja properties: project: myproject zone: us-central1-a resources:
    • name: datadisk-example-config-with-templates type: compute.v1.disk
    • name: vm-example-config-with-templates type: compute.v1.instance name: manifest-1427755258810-2b3498d9-530b-4f8e-b014-0342d3c9c66b selfLink: https://www.googleapis.com/deploymentmanager/v2/projects/myproject/global/deployments/example-config-with-templates/manifests/manifest-1436393348324

API

API で、GET リクエストにデプロイ名とマニフェスト名を指定します。

 GET https://www.googleapis.com/deploymentmanager/v2beta1/projects/myproject/global/deployments/example-deployment/manifests/manifest-1436393348324

次のようなレスポンスが返されます。

{
 "id": "7174699452487462421",
 "selfLink": "https://www.googleapis.com/deploymentmanager/v2/projects/myproject/global/deployments/example-config-with-templates/manifests/manifest-1436393348324",
 "creationTimestamp": "2015-03-30T15:40:58.815-07:00",
 "name": "manifest-1427755258810-2b3498d9-530b-4f8e-b014-0342d3c9c66b",
 "config": "imports: [\"vm_template.jinja\"]\n\nresources:\n- name: vm-instance\n  type: vm_template.jinja\n  properties:\n    zone: us-central1-a\n    project: myproject\n",
 "evaluatedConfig": "resources:\n- name: datadisk-example-config-with-templates\n  properties:\n    sizeGb: 100\n    type: https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/diskTypes/pd-standard\n    zone: us-central1-a\n  type: compute.v1.disk\n- name: vm-example-config-with-templates\n  properties:\n    disks:\n    - autoDelete: true\n      boot: true\n      deviceName: boot\n      initializeParams:\n        diskName: disk-example-config-with-templates\n        sourceImage: https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/debian-7-wheezy-v20140619\n      type: PERSISTENT\n    - autoDelete: true\n      deviceName: datadisk-example-config-with-templates\n      source: $(ref.datadisk-example-config-with-templates.selfLink)\n      type: PERSISTENT\n    machineType: https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/machineTypes/f1-micro\n    metadata:\n      items:\n      - key: startup-script\n        value: |\n          #!/bin/bash\n          python -m http.server 8080\n    networkInterfaces:\n    - accessConfigs:\n      - name: External NAT\n        type: ONE_TO_ONE_NAT\n      network: https://www.googleapis.com/compute/v1/projects/myproject/global/networks/default\n    zone: us-central1-a\n  type: compute.v1.instance\n",
 "layout": "resources:\n- name: vm-instance\n  properties:\n    project: myproject\n    zone: us-central1-a\n  resources:\n  - name: datadisk-example-config-with-templates\n    type: compute.v1.disk\n  - name: vm-example-config-with-templates\n    type: compute.v1.instance\n  type: vm_template.jinja\n"
}