Google Cloud Deployment Manager Tutorial
Introduction
Google Cloud Deployment Manager is an infrastructure deployment service that automates the creation and management of Google Cloud resources. With Deployment Manager, you can specify all the resources needed for your application in a declarative format using YAML, Python, or Jinja2 templates. This tutorial will guide you through the process of setting up and using Deployment Manager from start to finish.
Prerequisites
Before you begin, ensure you have the following:
- A Google Cloud project with billing enabled.
- The Google Cloud SDK installed on your local machine.
- Basic knowledge of YAML or Python.
Step 1: Setting Up Your Environment
First, authenticate with your Google Cloud account:
Set your desired project:
Enable the Deployment Manager API:
Step 2: Creating a Deployment Configuration
Create a YAML file named deployment.yaml
with the following content:
resources: - name: my-vm type: compute.v1.instance properties: zone: us-central1-a machineType: zones/us-central1-a/machineTypes/f1-micro disks: - deviceName: boot type: PERSISTENT boot: true autoDelete: true initializeParams: sourceImage: projects/debian-cloud/global/images/family/debian-9 networkInterfaces: - network: global/networks/default
This configuration defines a single VM instance in the us-central1-a
zone.
Step 3: Deploying the Configuration
Deploy the configuration using the following command:
After running the command, you should see output indicating the deployment is being created:
The fingerprint of the deployment is 3S2mt7X4z5U= Waiting for create [operation-1234567890123-abcdef] ............................done. Create operation operation-1234567890123-abcdef completed successfully. NAME TYPE STATE ERRORS my-vm compute.v1.instance COMPLETED []
Step 4: Updating the Deployment
To update the deployment, modify deployment.yaml
and run:
For example, to change the machine type, update the machineType
property:
machineType: zones/us-central1-a/machineTypes/n1-standard-1
Then run the update command.
Step 5: Deleting the Deployment
To delete the deployment, use the following command:
You will be prompted to confirm the deletion. Type y
and press Enter.
Conclusion
In this tutorial, you learned how to set up and use Google Cloud Deployment Manager to automate the deployment of Google Cloud resources. You created a deployment configuration, deployed it, updated it, and finally deleted it. Deployment Manager simplifies the management of your cloud infrastructure, making it easier to maintain consistency and scalability.