Understanding Google Cloud Deployment Manager

In the last post, I discussed Replica Pools and the benefit of using it for creating homogenous pool of GCE VMs. One of the key components of Replica Pools is the template. It contains the declaration of the pool along with a set of attributes. You could think of the template as the metadata of the Replica Pool. This template is actually based on a standard format defined by another related feature of Google Cloud Platform called the Deployment Manager. Let’s explore Google Cloud Deployment Manager and its use cases.
For those of you familiar with AWS CloudFormation, Deployment Manager concept wouldn’t be new. It allows you to declare, deploy and manage GCE resources. Like CloudFormation, Deployment Manager relies on JSON for describing the deployment. It also supports YAML as an alternative markup.
Deployment Manager is extremely useful when you need to create repeatable configuration that needs to be provisioned and de-provisioned multiple times. For example, product teams need to manage development, test and staging environments for multiple versions of the same product. They may no keep the resources running but need to bring up the environments selectively during the development process. By defining each environment as a deployment template, DevOps teams can easily create a deployment in a short notice. Since it is based on the same template, it is guaranteed to be consistent. With each minor change in the deployment, templates can be modified and versioned. This makes it efficient to manage the infrastructure configuration per each environment per version. Developers can treat it as an artifact by integrating the template with the source control system. The other use case of Deployment Manager is declaring a disaster recovery deployment template that is identical to the production environment. The template can be used in any region to quickly setup a DR site. Operations team should start with Deployment Manager templates instead of directly creating resources on Google Cloud. It makes the deployment efficient and less error prone.
Let’s take a close look at Deployment Manager. It has two building blocks -Template and Deployment.
DM
A Template contains the declaration of the deployment. For example, when launching a VM, it will have the machine type, the image, firewall rules, zone and other settings. Templates can be defined either in JSON or YAML. JSON is preferred when using the API since it can be directly embedded in the HTTP payload. When using the command line tools, Deployment Manager expects YAML configuration file. You can either create a new template from the scratch or modify an existing template. Google has provided two sample templates for PHP + Nginx and Node.js. Exploring them will give you an idea of the template structure.
Deployments are concrete instantiation of a template. They turn the declaration of the resources into actual deployment. It is possible to selectively override the settings defined in the template during the deployment. This feature can be used to leverage one template with minor changes that get applied during the deployment.
A Template can contain all the parameters that are used through the API or the command line tool. It can also contain commands that can be executed after launching the resources. For example, a template can contain “sudo apt-get update” command followed by the installation of required packages on a LAMP server running Debian. The following template declares a replica pool of 4 VMs in US-Central1-a zone. The actions section has the commands to install Apache web server on these VMs and creating index.html.
GCP_DM_Template
Like Replica Pools, Deployment Manager is in technical preview. To gain access to it, request to be whitelisted.
In the future posts, we will explore using the combination of Deployment Manager and Replica Pools feature to deploy a load balanced, self-healing, auto-scaled deployment on Google Cloud.

Written by

Janakiram MSV heads the Cloud Infrastructure Services at Aditi Technologies. He contributes to cloud related articles on YourStory.com. A former employee of Microsoft and Amazon, Janakiram built a cloud consulting company that recently got acquired by Aditi Technologies. He is an analyst with Gigaom Research contributing to the Cloud related market research and analysis. He can be reached at jani@janakiram.com.

Related Posts