DevOps Automation using Google Deployment Manager
Megha kadur
Senior Software Engineer | Azure Certified | 22K + LinkedIn | GitOps certified | DevOps Speaker | 9K + subscribers on Youtube | Helping people break into DevOps
What is Infrastructure as code?
Benefits of IaC:
Let's have a look at how Google Cloud Deployment Manager allows us to automate the task by the use of a configuration file that includes GCP Resources.
Pre-requisites required for GCP: -?
Note: Before starting any coding set up your project -id, run the below-mentioned command within Cloud Shell.
How to Define your Resources:
Create a YAML syntax, which describes your resources in a configuration file.
# Code credit: - cloud.google.com documents (code reference)
#Link: https://cloud.google.com/deployment-manager/docs/manage-cloud-resources-deployment
resources:
- type: compute.v1.instance
? name: quickstart-deployment
? properties:
? ? zone: us-central1-f
? ? # Replace [MY_PROJECT] with your project ID
? ? 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
? ? # Replace [MY_PROJECT] with your project ID
? ? networkInterfaces:
? ? - network: https://www.googleapis.com/compute/v1/projects/[MY_PROJECT]/global/networks/default
? ? ?
? ? ? accessConfigs:
? ? ? - name: External NAT
- type: ONE_TO_ONE_NAT
?This basic configuration describes the properties of virtual machines like machine type, zone, and image family, also need to replace [MYPROJECT_ID] with your Project ID.
领英推荐
Deploy the resources:
gcloud deployment-manager deployments create quickstart-deployment --config vm.yaml
Create operation operation-1432319707382-5b7103978 completed successfully.
NAME? ? ? ? ? ? ? ? ? ? TYPE? ? ? ? ? ? ? ? STATE? ? ? ERRORS
quickstart-deployment ? compute.v1.instance COMPLETED? -
gcloud deployment-manager deployments describe quickstart-deployment
gcloud deployment-manager deployments delete quickstart-deployment