You are currently viewing How To Create A Compute Engine Instance Using gcloud

How To Create A Compute Engine Instance Using gcloud

How to create a compute engine instance using gcloud

Hello Everyone

Welcome to CloudAffaire and this is Debjeet.

In the last blog post, we have learned the basic concepts of gcloud.

https://cloudaffaire.com/gcloud-core-concepts/

In this blog post, we will start with one of the core components of GCP, compute engine. Compute Engine lets you create and run virtual machines on Google infrastructure. Compute Engine offers scale, performance, and value that allows you to easily launch large compute clusters on Google’s infrastructure. There are no upfront investments and you can run thousands of virtual CPUs on a system that has been designed to be fast and to offer strong consistency of performance.

Compute Engine configuration options:

Name: A name for your compute instance, name must start with a lowercase letter followed by up to 62 lowercase letters, numbers, or hyphens, and cannot end with a hyphen

Region: A region is a specific geographical location where you can run your resources.

Zone: A zone is an isolated location within a region. The zone determines what computing resources are available and where your data is stored and used

Machine Type: Machine types are grouped and curated by families for different workloads like general-purpose, memory-optimized, and compute-optimized.

CPU Platform: The microarchitecture of your VM instance. Select ‘Automatic’ unless you have a specific need.

GPU: Compute Engine provides graphics processing units (GPUs) that you can add to your virtual machine instances. You can use these GPUs to accelerate specific workloads on your instances such as machine learning and data processing.

Display device: These devices allow you to run remote system management tools and remote desktop software that require a display device.

Container: You can deploy a container to this VM instance by using a container-optimized OS image

Boot disk: Each instance requires a disk to boot from. Select an image or snapshot to create a new boot disk or attach an existing disk to the instance.

Boot disk type: Storage space is much less expensive for a standard persistent disk. An SSD persistent disk is better for random IOPS or streaming throughput with low latency

Boot disk Size: Persistent disk performance is tied to the size of the persistent disk volume. You are charged for the actual amount of provisioned disk space.

Boot disk image: Select an image or snapshot to create a boot disk; or attach an existing disk.

Service Account: Applications running on the VM use the service account to call Google Cloud APIs. Use Permissions on the console menu to create a service account or use the default service account if available.

Access scope: Select the type and level of API access to grant the VM. Default: read-only access to Storage and Service Management, write access to Stackdriver Logging and Monitoring, read/write access to Service Control.

Firewall: By default, all incoming traffic from outside a network is blocked. Select the type of network traffic you want to allow. Currently, only http and https are allowed.

Labels: To organize your project, add arbitrary labels as key/value pairs to your resources. Use labels to indicate different environments, services, teams, and so on.

Delete Protection: By setting the deletionProtection flag, a VM instance can be protected from accidental deletion. If a user attempts to delete a VM instance for which you have set the deletionProtection flag, the request fails. Only a user that has been granted a role with compute.instances.create permission can reset the flag to allow the resource to be deleted.

Reservation: Create reservations for VM instances in a specific zone, using custom or predefined machine types, with or without additional GPUs or local SSDs, to ensure resources are available for your workloads when you need them.

Startup script: You can choose to specify a startup script that will run when your instance boots up or restarts. Startup scripts can be used to install software and updates, and to ensure that services are running within the virtual machine.

Metadata: You can set custom metadata for an instance or project outside of the server-defined metadata. This is useful for passing in arbitrary values to your project or instance that can be queried by your code on the instance.

Preemptibility: A preemptible VM costs much less, but lasts only 24 hours. It can be terminated sooner due to system demands.

On host maintenance: When Compute Engine performs periodic infrastructure maintenance it can migrate your VM instances to other hardware without downtime

Automatic restart: Compute Engine can automatically restart VM instances if they are terminated for non-user-initiated reasons (maintenance event, hardware failure, software failure and so on)

Shielded VM: Shielded VM features include trusted UEFI firmware and come with options for Secure Boot, vTPM, and Integrity Monitoring.

SSH Key: These keys allow access only to this instance, unlike project-wide SSH keys

Block project-wide SSH keys: When checked, project-wide SSH keys cannot access this instance

Boot disk Deletion rule: When checked, deletes boot disk when the instance is deleted.

Encryption: Manage encryption at rest for your instance data.

Device name: You can use this name to reference the device for mounting, resizing, and so on, from within the instance. You can select to generate the device name based on instance name or put a custom name.

Additional Disk: Additional disks provide persistent and local ssd storage for the instance

Network Tags: Assign network tags to apply firewall rules to specific VM instances.

Hostname: Set a custom hostname for this instance or leave it default. Choice is permanent

Network Interface: Each VM instance can have 1 to 8 network interfaces. Networks without subnetworks do not support instances with multiple network interfaces.

Sole tenancy: A sole-tenant node is a physical Compute Engine server that is dedicated to hosting VM instances only for your specific project. Use sole-tenant nodes to keep your instances physically separated from instances in other projects, or to group your instances together on the same host hardware.

How to create a compute engine instance using gcloud:

Or you can ssh to the instance directly from the console.

Hope you have enjoyed this article. All the public cloud providers are changing the console user interface rapidly and due to this some of the screenshots used in our previous AWS blogs are no longer relevant. Hence, we have decided that from now onwards most of the demo will be done programmatically. Let us know your feedback on this in the comment section.

To get more details on compute instance, please refer below GCP documentation.

https://cloud.google.com/compute/docs/

 

 

Leave a Reply