Glen Elkins
Glen Elkins

Reputation: 917

Google Compute Engine Stop Hostname From Resetting On Reboot

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

Answers (1)

Sirui Sun
Sirui Sun

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

More info the docs.

Upvotes: 1

Related Questions