在启动时为GCE实例配置FQDN

编程入门 行业动态 更新时间:2024-10-13 04:22:23
本文介绍了在启动时为GCE实例配置FQDN的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试使用预先配置的FQDN启动Google计算引擎(GCE)实例.我们打算运行一个基于/etc/hosts内容获得许可的应用程序.

I am trying to start a google compute engine (GCE) instance with a pre-configured FQDN. We are intending to run an application that is licensed based on the contents of /etc/hosts.

我正在使用Google Cloud SDK实用程序-gcloud启动实例.

I am starting the instances using the Google Cloud SDK utility - gcloud.

我尝试使用元数据选项设置主机名"键,如下所示:

I have tried setting the "hostname" key using the metadata option like so:

gcloud compute instances create mynode (standard opts) --metadata hostname=mynode.example

每当我登录开发人员控制台时,在计算机,实例下,都可以在自定义元数据"下看到主机名.这似乎是一个新的自定义键-对以下内容没有影响:

Whenever I log into the developer console, under computer, instances, I can see hostname under "Custom metadata". This appears to be a new, custome key - it has no impact on what:

metadata.google.internal/computeMetadata/v1/instance/hostname

返回.

我还尝试过如下设置实例/主机名",这在使用gcloud时会导致解析错误.

I have also tried setting "instance/hostname" like the below, which causes a parsing error when using gcloud.

--metadata instance/hostname=mynode.example

我已经成功地使用了元数据服务器的启动脚本功能来运行启动脚本,该脚本解析新创建的实例(更新的/etc/hosts)的新的内部IP地址.这似乎可行,但感觉不像"google方式".

I have successfully used the startup scripts functionality of the metadata server to run a startup script that parses the new, internal IP address of the newly created instance, updated /etc/hosts. This appears to work but doesn't feel "like the google way".

我可以在实例创建期间使用配置实例的 FQDN (具体来说是域名,因为实例名称始终是主机名) >元服务器功能?

Can I configure the FQDN (specifically, a domain name, as the instance name is always the hostname) of an instance, during instance creation, using the metaserver functionality?

推荐答案

根据本文主机名"是提供有关您的实例信息的默认元数据条目的一部分,无法手动编辑任何默认元数据对.您还可以观看Google团队的此视频.在开始的几分钟内,提到您不能修改默认元数据对.因此,除了像已经完成的那样使用启动脚本之外,似乎无法在创建实例时指定主机名.还值得一提的是,除非您使用启动脚本或每次都会对其进行修改的内容,否则指定的主机名将在重新启动后由元数据服务器删除并自动同步.

According to this article 'hostname' is part of the default metadata entries that provide information about your instance and it is NOT possible to manually edit any of the default metadata pairs. You can also take a look at this video from the Google Team. Within the first few minutes it is mentioned that you cannot modify default metadata pairs. As such, it does not seem like you can specify the hostname upon instance creation other than through the use of a start-up script like you've done already. It is also worth mentioning that the hostname you've specified will get deleted and auto-synced by the metadata server upon reboot unless you're using a start-up script or something that would modify it every time.

如果您当前正在做的事情能够满足您要完成的任务,那么这可能是解决方案的唯一解决方法.

If what you're currently doing works for what you're trying to accomplish, it might be the only workaround to your scenario.

更多推荐

在启动时为GCE实例配置FQDN

本文发布于:2023-11-25 15:08:13,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1630234.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:启动时   实例   GCE   FQDN

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!