We will learn how to generate a custom Image on Google Compute Engine in this article. You can import a boot disc image called a “custom image” from your on-premises environment or another cloud platform to Compute Engine. This blog post will walk you through each step of creating a custom image in Google Compute Engine on the Google Cloud Platform.
Let’s get started and learn more about custom images in this article. Keep checking back here as I continue to produce several articles on Google Cloud.
Note – Please bookmark this below page to access all posts regarding Google Cloud Digital Leader certification.
Read this blog post or watch the video below to learn how to create Custom Images in Google Cloud Platform.
What Is Custom Image
Utilizing a custom image will speed up the installation of software and OS patches during the launch of VM instances. Therefore, it takes a long time to run a virtual machine instance whenever you build one and install a lot of applications or OS patches. The ideal strategy is to generate a custom image with OS patches and apps pre-installed in order to skip the above process. You may therefore use that custom image to generate one or more instances by doing this. You can actually create a custom image in Google Cloud using a variety of tools, including instances, persistent discs, snapshots, and cloud storage. Once the custom image has been developed, it is possible to share it across projects.
The ability to deprecate all images is another capability offered by Google Cloud. Therefore, you always have the choice to mark an image as deprecated if it has been around for a while.
Create Custom Image
Creating a Custom Image in the Google Cloud Platform needs a couple of steps. So in this blog post, I am going to share all the steps you need to perform and here are they –
Let’s say I have this Virtual Machine (screenshot below) which is already having an Apache server installed. Every Virtual Machine runs on a disk. So I will be using this disk to create the image.
Create An Image
To create an image from a disk, the first thing you need to do is stop the Virtual Machine this is linked to this image. It is not required, but it is a kind of best practice to always stop the virtual machine before using the associated disk to create custom image.
Hard discs, sometimes known as discs, are what your virtual computers are connected to. The operating system of the virtual machine operates on the hard disc that is connected to the specific VM whenever you build one.
Therefore, I will select the Create Image option from the Action menu in order to make a duplicate of this particular disc.
Once I click on the Create image, I will see the image creation menu in the below screen. Here, I will give the image name.
I want to change the location to Multi-Regional as I want my virtual machines to run in multiple regions.
Once I create the image, I can find my custom image under Storage -> Images section.
Create An Instance Template From The Image
After creating an image I will click on the Instance template from the left navigation menu and select the instance template. Here, I will click on “Create Instance Template”. I will give it a name. But most important thing is to change the Boot Disk and select the custom image I have just created.
This way, I can change the standard boot disk and use my custom image. Now this custom image is already having an apache server installed and configured. So any virtual machine I will create from this new instance template, I don’t need to install an apache server and configure it. The only thing that I need to do is to start the apache server. And I can do this by writing startup scripts.
Configure The Startup Script
On this same page, I will click on “Advanced Options” and expand the “Management” section to write the startup script, which will configure and start the apache server on every virtual machine that I will create from this instance template.
Create A New Virual Machine From Instance Template
This time I will create a new Virtual Machine from this Instance Template and test it. I have a dedicated blog and youtube video where I covered how to create Virtual Machine from Instance Template. The links are given below –
Below is the new Virtual Machine created from Instance Template.
Now when I click on the External IP, I can see the custom message coming from index.html which is configured in the apache server. And the important point is that I don’t need to do any configuration like installing the apache server, updating the index.html page, etc. All the configurations are stored in the custom image and I literally used that image to create the template and finally virtual machine from there.
Because I don’t have to wait for the package to install before the VM starts, utilizing a custom image has the advantage of making boot time a little bit quicker. So now you also know how to make a unique custom image and use that image to make a virtual machine using an instance template.
I’m hoping that this article may assist you in using Google Compute Engine to create a custom image. I will publish many more articles on Google Cloud in the upcoming blog.
This article is not endorsed by Salesforce, Google, or any other company in any way. I shared my knowledge on this topic in this blog post. Please always refer to Official Documentation for the latest information.