Google Cloud Platform – Deployment Manager

Create a Home page in ASP.Net Core 3.1 MVC

Deployment Manager allows you to create templates of your resources or applications that can easily be deployed ondemand. This allows for automation and management of GCP resources using YAML-based configuration files. For example, if your company has an application that is often deployed, you can create a Deployment Manager template for it and run it every time the application needs to be deployed.

Let’s look at some basic concepts of Deployment Manager:

  • Configuration: A configuration describes all the resources that are part of a single deployment. The resources can be anything—GCP compute instances, app engine instances, or storage buckets. The configuration file is written in YAML and consists of each resource type along with its properties. Every resource must have a name, a type, and its properties.
  • Template: Templates are parts of configuration files that have been abstracted into individual blocks. For example, as part of every app deployment, if you create four compute engine instances and three BigQuery data tables, then this process can be made part of a template and included in different configuration files. A template file is written in either Python or Jinja 2.
  • Types: Every resource in Deployment Manager has a type associated with it. A type can be a single API resource known as a base type or a set of resources known as a composite type.
  • Manifest: A manifest is a read-only object that contains the original configuration you provided to the Deployment Manager. Every time the deployment manager is updated, a new manifest file is generated.

Let’s explore Deployment Manager in the GCP Console:

  1. Log in to your GCP console and click on Deployment Manager which is listed under TOOLS:
  1. We will deploy a single VM configuration using Deployment Manager. If you haven’t already, download and install the cloud SDK.
  2. Set the project ID:
$ gcloud config set project stackdriver-test-project
Updated property [core/project].
Replace the stackdriver-test-project with your own project name. 
  1. Next, we create a configuration file in YAML. A configuration file starts with the resources string. On your machine, create a folder and create a file called 1-vm.yaml. In this YAML file, type the following code. Be mindful of the spaces and remember not to use tabs for spacing.
  2. In the following file, we mention the name of our virtual machine and the instance type. We also have the zone on which this gets deployed. This will override any default zone that is part of your gcloud config. We have also mentioned the disks and the network settings for this deployment:
- name: my-vm
   type: compute.v1.instance
     zone: us-central1-f
     - deviceName: boot
       type: PERSISTENT
       boot: true
       autoDelete: true
     - network:
       - name: External NAT
         type: ONE_TO_ONE_NAT
Replace myproject with the name of your project. 

  1. Save changes to the file. To deploy this configuration, run this command:
$ gcloud deployment-manager deployments create deployment-1-vm --config 1-vm.yaml
  1. If the deployment manager API is not enabled, you will see the following message: 
API [] not enabled on project[414958921078]. Would you like to enable and retry (this will take a few minutes)? (Y/N)?
  1. Type in Y to continue:
     create operation
     operation operation
    b792463 completed successfully
NAME           TYPE                 STATE      ERRORS  INTENT
    vm   compute
    instance  COMPLETED  

You have successfully created a new deployment.

It is important to remember that deleting a deployment will also delete all resources deployed by that deployment. To delete this deployment, enter:
$ gcloud deployment-manager deployments delete 1-vmdeploy.

Comments are closed.