This page describes how to create a deployment. A deployment is an instantiation of a set of resources that are defined in a configuration. You provide a valid configuration in the request to create the deployment. A deployment can contain a number of resources, across a variety of Google Cloud services. When you create a deployment, Deployment Manager creates all of the described resources in the respective Google Cloud APIs.
Before you begin
- If you want to use the command-line examples in this guide, install the `gcloud` command-line tool.
- If you want to use the API examples in this guide, set up API access.
- Create a configuration.
Creating a deployment
When you create a deployment, you are creating a Deployment resource that contains a collection of resources. Each resource is explicitly defined in a configuration that you provide in your request.
gcloud
With the Google Cloud CLI, use the deployments create command:
gcloud deployment-manager deployments create my-first-deployment \
--config vm.yaml
The --config flag is a relative path to your YAML configuration
file.
By default, if your configuration includes resources that are already
in your project, those resources are acquired by the deployment, and can
be managed using the deployment. If you don't want to acquire a resource,
you must use the --create-policy option, as in the following gcloud beta
command:
gcloud beta deployment-manager deployments create my-first-deployment \
--config vm.yaml --create-policy CREATE
For information on what policies you can use when you are creating deployments, see Setting the policy for creating resources.
If your deployment is successfully created, you can get a description of the deployment:
gcloud deployment-manager deployments describe my-first-deployment
API
In the API, make an insert()
request with the configuration provided inline, in the request body:
POST https://www.googleapis.com/deploymentmanager/v2/projects/myproject/global/deployments
{
"name": "example-config-with-templates",
"target": {
"config": {
"content": "resources:\n- name: vm-created-by-cloud-config\n type: compute.v1.instance\n properties:\n zone: us-central1-a\n machineType: https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/machineTypes/n1-standard-1\n disks:\n - deviceName: boot\n type: PERSISTENT\n boot: true\n autoDelete: true\n initializeParams:\n diskName: disk-created-by-cloud-config\n sourceImage: https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/debian-7-wheezy-v20151104\n networkInterfaces:\n - network: https://www.googleapis.com/compute/v1/projects/myproject/global/networks/default\n"
}
}
}
If you import templates, you must also provide those
templates as part of the request body. For example, the following API request
has a target that imports one template, named vm_template.jinja:
POST https://www-www.googleapis.com/deploymentmanager/v2/projects/myproject/global/deployments
{
"name": "my-example-config-with-templates-2",