How to use GCP Deployment Manager

Basic usage of Google Cloud Platform (GCP) Deployment Manager for VM instances1 min


We will use Google Cloud Platform Deployment Manager in this tutorial. Deployment manager uses a system of templates to consistently deploy GCP resources. You create files to instruct Deployment Manager.

Create a Project or use an existing one, Deployment Manager requires a GCP Console project to use.

First we will login to GCP account. Then open Google Cloud Shell (gcloud).

Create a folder for the Deployment Manager files.

$ mkdir myfirstdeployman
$ cd myfirstdeployman

Creating a Configuration

We will create the YAML file and add the basic configuration for Virtual Machine instance. We will use nano as for the text editor. Note: replace [MY_PROJECT] with the project ID from GCP console.

$ nano my-vm.yaml
resources:
– name: my-vm
  type: compute.v1.instance
  properties:
    zone: us-central1-f
    machineType: https://www.googleapis.com/compute/v1/projects/[MY_PROJECT]/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/[MY_PROJECT]/global/networks/default
      accessConfigs:
      – name: External NAT
        type: ONE_TO_ONE_NAT

This configuration file will be used to create a virtual machine called “my-vm”, the machine type will be “f1-micro”, zone will be “us-centeral1-f” and the image will be debian-9.

Create the deployment using the below command

$ gcloud deployment-manager deployments create my-first-vm-deployment –config my-vm.yaml

It could take few minutes to complete, you should see an output like below

.
.
.
NAME   TYPE                 STATE      ERRORS  INTENT
my-vm  compute.v1.instance  COMPLETED  []

Now you can go and check your new VM should be created and listed on Computer Engine>VM Instances.

If you encountered an error during the creating of the deployment manager, or you want to undo/delete use the below command

$ gcloud deployment-manager deployments delete my-first-vm-deployment

This will delete any resources in the your deployment file.


Like it? Share with your friends!

Hasan

0 Comments

Your email address will not be published. Required fields are marked *

Choose A Format
Story
Formatted Text with Embeds and Visuals