Deployment Manager is an infrastructure deployment service that automates the creation and management of Google Cloud Platform resources like computing, databases, storage and networking. You can write flexible templates and configuration files and use them to create deployments that have a variety of Cloud Platform services, such as Google Cloud Storage, Google Compute Engine, and Google Cloud SQL configured to work together. Management of these cloud environments is done by using an infrastructure-as-a-code approach.
Creating a Configuration File
Create a new Project. I created Deployment Manager Demo as my project.
2. Click on the Activate Cloud Shell icon
3. After logging in, it takes few minutes to provision and connect to the environment. Once connected, you are already authenticated with the project id – deployment-manager-demo-325107 (this being my project id here)
4. Here, we are using gcloud to run all our commands to demonstrate a simple deployment manager demo.
Using the gcloud command gcloud auth list, I’ve listed the active account name associated.
Likewise, you can also list down the active project id associated with it using the command: gcloud config list project
References for gcloud: https://cloud.google.com/sdk/docs/cheatsheet
5. We can create a YAML file that will have all the configurations describing a single document. Hence, created a YAML file with the below command:
6. Added the below configuration in the newly created YAML file and then saved it. You can refer to the resources to be added from the link:
You can also refer to the below link of how to create a configuration file in the deployment manager:
resources: - type: compute.v1.instance name: my-first-ever-deployment properties: zone: us-central1-f machineType: https://www.googleapis.com/compute/v1/projects/deployment-manager-demo-325107/zones/us-central1-f/machineTypes/f1-micro disks: - deviceName: boot type: PERSISTENT boot: true autoDelete: true initializeParams: sourceImage: https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/family/debian-9 networkInterfaces: - network: https://www.googleapis.com/compute/v1/projects/deployment-manager-demo-325107/global/networks/default accessConfigs: - name: External NAT type: ONE_TO_ONE_NAT
The resources used are specified as below:
- Zone : us-central1-f
- Machine type : f1-micro
- Root persistent disk : disk-my-first-deployment
- Image : debian-9
- A randomly assigned external IP address
After pasting the above configuration, save the YAML file as vm.yaml (or any name you want).
Deploying the Configuration file
For deploying the configuration file, you must execute the below command:
gcloud deployment-manager deployments create my-first-deployment --config vm.yaml
my-first-deployment: name of the instance
deploy-man.yaml: name of the configuration specifying the details of the resources
When you run the above command, you will be prompted to enable certain APIs for compute engine (if you have not done already).
When your deployment will be successful and you will get the below message:
You can verify the newly created instance in Compute Engine –> VM Instances
References for creating a deployment:
Viewing the details of the deployment
You can view the information of the deployment by running the below command:
gcloud deployment-manager deployments describe my-first-deployment
You should see a description of your deployment, including its start and end time, the deployment status, and any warnings or errors if applicable.
You will get the below output:
Similarly for deleting a resource, you can use the below command:
gcloud deployment-manager deployments delete my-first-deployment
The output will be:
A manifest is a read-only object that contains the original configuration you provided, including any imported templates, and also contains the fully-expanded resource list, created by the Deployment Manager. Each time you update a deployment, Deployment Manager generates a new manifest file to reflect the new state of the deployment. When troubleshooting an issue with deployment, it is useful to view the manifest.
You can get the manifest of the deployment when you view the deployment details (see above pic). You get manifest-1630830972038 which is actually manifest-<timestamp>
For viewing manifest, you must run the below command:
gcloud deployment-manager manifests describe <manifest-[TIMESTAMP]> --deployment my-first-deployment
hence, the command will be:
gcloud deployment-manager manifests describe manifest-1630830972038 --deployment my-first-deployment
Reference for viewing manifests:
Creating your own DM template
While developing an application, you will most likely require complex architectures. To make your deployment easier to replicate and troubleshoot, we recommend that you break your configuration into templates.
A template is a separate file that defines a set of resources. You can reuse templates across different deployments, which creates consistency across complex deployments.
You can use Python or Jinja2 to create templates for Deployment Manager.
Reference for creating your own template engine:
- Google Cloud Deployment Manager allows you to specify all the resources needed for your application in a declarative format using yaml.
- Repeatable deployment process by creating configuration files that define the resources, the process of creating those resources can be repeated over and over with consistent results.
- Declarative approach allows the user to specify what the configuration should be and let the system figure out the steps to take.
- It is template-driven which means the template allows the use of building blocks to create abstractions or sets of resources that are typically deployed together. Hence, the templates can be used over and over again as these are easily parameterized.
Deployment Manager Fundamentals:
Reference for Automation Scripts, CICD, Building templates:
Reference for AWS CloudFormation Vs Google Deployment Manager: