Hello.
I’m running couple of GVMs in Anthos cluster using VM runtime. For one of these GVMs I need to set hostname that is different from GVM name.
I tried to set it internally using hostnamectl, but every time I reboot the VM, hostname changes to GVM name
hostname <string>
Specifies the hostname of the vmi If not specified, the hostname will be set
to the name of the vmi, if dhcp or cloud-init is configured properly.
If you’re wondering if you can pass a custom hostname to a VM runtime in Anthos, there are ways to manage VM networking and hostname configuration. However, this depends on the VM runtime you’re using and how the VM is connected to the Anthos cluster.
You may refer to the following instructions below, a sample on how to create a VM by directly applying a VirtualMachine YAML manifest file with the kubectl CLI.
Create a manifest that defines a VirtualMachine, such as my-vm.yaml, in the editor of your choice: