Create instances in Google Cloud with Private Image

khushbu parakh
2 min readMar 19, 2019

--

Image creation workflow:

  • Step1: Create a file
  • Step2: Create a bucket and upload that file to the bucket
  • Step3: Create an image out of it
  • Step4: Create an instance from that private image

Description of all steps.

Step1: Importing Virtual Disks: The import tool supports most virtual disk file formats, including VMDK, VHD, and RAW.

You are going to prepare your boot disk image before you upload it. The image file that you import must meet the following requirements:

  • The disk image file name must be disk.raw.
  • The RAW image file must have a size in an increment of 1 GB. For example, the file must be either 10 GB or 11 GB but not 10.5 GB.
  • The compressed file must be a .tar.gz file that uses gzip compression and the GNU tar format.

If you configured your instance to use a service account with a Google Cloud Storage scope, you can use the Cloud Storage APIs to write data to Cloud Storage buckets.

  1. Install and configure a client library for your preferred language.
  2. Follow one of the code samples and include code in your application that writes a file to a Cloud Storage bucket.

Step2: Then upload the bucket files to create an image with source cloud storage:

It’s the same API’s to create and start an instance.

Create an image out of the file uploaded.

Here is an example of creating an instance with Bucket file.

Machine type for your instance

In general, the following rules apply for n1-standard-x, n1-highmem-x, n1-highcpu-x, f1-micro, g1-small and custom VMs:

  • 2 network interfaces for VM <= 2vCPU
  • 1 network interface per vCPU for VM > 2vCPUs, with a cap of max 8 network interfaces per VM

Use the following table to determine how many network interfaces can be attached to an instance:

I am sharing the GitHub link of code all you need to do it create a tar.gz file and good to go.

https://github.com/khushbuparakh/gcp/blob/master/instance.py

#computeengine #gcp #gce #storage #images.

--

--

khushbu parakh
khushbu parakh

No responses yet