GCP Free Learning
, ,

How to create a custom machine type in Compute Engine in GCP?

by

GCP Free Learning

Creating a custom machine type in Compute Engine allows you to tailor the number of vCPUs and memory to fit your specific use case. Here’s how to create a custom machine type using GCP Console, gcloud CLI, and Terraform:

1. Using GCP Console:

a. Go to the GCP Console: https://console.cloud.google.com/

b. Navigate to Compute Engine > VM instances.

c. Click on the “Create instance” button.

d. Fill in the required fields, and under “Machine type”, click on the “Customize” button.

e. Adjust the number of vCPUs and the amount of memory as needed. Note the custom machine type format: custom-CPUS-MEMORY, where CPUS is the number of vCPUs and MEMORY is the memory in MiB.

f. Finish configuring the instance and click the “Create” button.

2. Using gcloud CLI:

a. Run the following command to create a VM instance with a custom machine type:

gcloud compute instances create INSTANCE_NAME \
    --machine-type custom-CPUS-MEMORY \
    --image-family IMAGE_FAMILY \
    --image-project IMAGE_PROJECT \
    --boot-disk-size BOOT_DISK_SIZE \
    --zone ZONE

Replace INSTANCE_NAME, CPUS, MEMORY, IMAGE_FAMILY, IMAGE_PROJECT, BOOT_DISK_SIZE, and ZONE with appropriate values.

3. Using Terraform:

a. Create a main.tf file with the following resource block:

resource "google_compute_instance" "example" {
  name         = "example-instance"
  machine_type = "custom-CPUS-MEMORY"
  zone         = "ZONE"

  boot_disk {
    initialize_params {
      image = "projects/IMAGE_PROJECT/global/images/family/IMAGE_FAMILY"
      size  = BOOT_DISK_SIZE
    }
  }

  network_interface {
    network = "default"
    access_config {
      // Ephemeral IP
    }
  }
}

Replace CPUS, MEMORY, ZONE, IMAGE_FAMILY, IMAGE_PROJECT, and BOOT_DISK_SIZE with appropriate values.

b. Run the following commands to apply the changes:

terraform init
terraform plan
terraform apply

This will create a new Compute Engine instance with a custom machine type tailored to your requirements.

Glance and Google’s Next-Level Gaming Recommendation Engine

Collaborative Excellence: Glance and Google’s Next-Level Gaming Recommendation Engine Introduction: In the dynamic gaming industry, personalized recommendations are crucial for..

gcp_ml gcp_ml

Digits and Google Cloud ML

How Digits is Transforming the Accounting Landscape Using Google Cloud ML The finance and accounting industry is experiencing a significant..

GCP AI GCP AI

Google Cloud’s Vertex AI Model Garden and the Launch of Generative AI Studio

Google Cloud’s Vertex AI Model Garden and the Launch of Generative AI Studio Artificial Intelligence (AI) and Machine Learning (ML)..

GCP AI/ML GCP AI/ML

Google Cloud’s Pioneering AI Models and the Launch of Generative AI Studio

 Google Cloud’s Pioneering AI Models and the Launch of Generative AI Studio Artificial Intelligence (AI) continues to break new grounds,..

GCP App Engine GCP App Engine

How to scale an App Engine application in GCP?

Scaling an App Engine application involves configuring the scaling settings in the app.yaml file and deploying the changes. I’ll provide..

Leave a Reply

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