Reputation: 917
I know this question has been asked already but I can not find a solution that actually works! The main solution that I have found everywhere and tried is by setting a cron job for when the system reboots with :
@reboot hostname $(curl --silent "http://metadata.google.internal/computeMetadata/v1/instance/attributes/hostname" -H "Metadata-Flavor: Google")
This is after adding the metadata hostname
key in the instance settings and it just doesn't work and the hostname keeps getting reset to the name of the instance (I need it as a FQD)
Does anyone have a working solution?
Upvotes: 3
Views: 93
Reputation: 626
At creation time, you can set a custom FQDN hostname for your VMs via the optional hostname property. This feature is currently in Beta. ex:
gcloud beta compute instances create INSTANCE_NAME --hostname custom.hostname.xyz
Upvotes: 1