In #GCP #Compute #Engine you can now rename a VM in the cloud console easily by just using a single command in #Cloud Shell.
There are many reasons why you may need to rename a #VM in GCP, those reasons can be either any or a mix of:
Better represents the workload running on the instance
Refers to the operating system running on the instance
Adheres to any naming conventions required by your organization
Previously, this was not possible to do in #Google Cloud Platform, and in order to do that, you would need to go through a long process by deleting the instance that you want to rename, while preserving its boot and any additional disks, and also by making sure all the required metadata and settings such as IPs whether internal or external are also preserved or recorded in order to be used later on, while recreating the instance with the new name.
This was a very long process that involves downtime for the critical workloads that are required to be renamed, which will badly affect the business.
But if you look at this in #AWS, then you can easily rename EC2 instances from the console or portal, however that name does not affect anything in the VM, and it is just for description purposes. In #Azure & GCP it is different, as the name of the VM can affect a few aspects in the VM itself; and in Azure, the only way to rename a VM is to follow the same approach mentioned above.
Now in GCP, you can rename a VM without going through the above approach, and you only need to stop the instance for the duration of the execution of:
gcloud beta compute instances set-name INSTANCE_NAME --new-name=NEW_INSTANCE_NAME
One of the most important effects of the VM name on a VM instance in GCP, is that the hostname will be similar to the VM name from the Cloud Console. This is more clear effect when you are using Linux VMs, because of the Transient hostname that will override the static hostname of your VM upon each reboot, and no matter what you do inside the Linux OS, the hostname will always be reset on reboot because of the transient hostname will be retrieved from the VM's metadata and the DHCP service and be applied on the VM.
So in case you want to change the VM's hostname in this case, you will either need to setup a startup script to change the transient hostname or by just renaming the VM instance as explained in this video!
--------------------------------------------------
Video chapters/timeline:
00:00 - Introduction
01:40 - Why you may need to rename a GCP VM instance?
03:08 - How the VM name will affect the OS hostname in GCP
04:03 - Rename a VM in GCP by deleting and recreating the VM
05:37 - Important points and considerations before renaming a VM instance in GCP
09:18 - Required permissions and roles to rename a VM in GCP
11:24 - How to rename a VM in GCP using gcloud beta compute set-name
17:03 - Closing
--------------------------------------------------
Please don't forget to like the video to help it reach more people, and also please subscribe to the channel and click that bell button!
--------------------------------------------------
Links mentioned in the video:
Avoid overwriting of hostname by transient hostname at reboot https://unix.stackexchange.com/questi...
Renaming an instance | Compute Engine Documentation | Google Cloud https://cloud.google.com/compute/docs...
Check out my website: https://www.salehram.com
Also check out my Google Workspace Admin training and course, this is a full comprehensive course about almost everything in Google Workspace. You can get it at a discounted price through this link: https://www.udemy.com/course/the-comp...
--------------------------------------------------
Interesting channels to follow and subscribe:
Google Workspace - / @googleworkspace
Google Cloud Tech - / @googlecloudtech
Google Cloud - / @googlecloud
Learn GCP with Mahesh - / @learngooglecloudwithmahesh
Watch video GCP | How to rename a VM instance or change the host name in GCP Compute Engine? | GCP training online without registration, duration hours minute second in high quality. This video was added by user The Cloud Nerd 28 September 2021, don't forget to share it with your friends and acquaintances, it has been viewed on our site 3,165 once and liked it 44 people.