gcloud - 谷歌CP : assign/remove ephemeral IP to an existing instance

标签 gcloud google-cloud-platform

我在 GCP 中只有几个实例,出于管理目的,我需要在 SSH 中进行短暂连接并启动一些命令。这些实例在“正常”模式下没有外部 IP,但对于这些简短的维护,我想分配临时 IP,进行维护,然后删除它们。

可以在 Web 界面上轻松完成此操作(编辑实例更改 NIC 配置以添加临时 NAT IP),但我想避免这种情况,因为我有多个实例...我是否在 gcloud 文档中遗漏了某些内容?

最佳答案

在探索 gcloud 文档的深层部分(太长时间)后找到了它。

在专门为实例分配静态外部 IP 地址的部分中(是的,在静态部分),它在一个小注释中写道:

"If you intend to use an ephemeral external IP address, you can skip this step, and Compute Engine will randomly assign an ephemeral external IP address."

https://cloud.google.com/compute/docs/ip-addresses/reserve-static-external-ip-address#ipassign

因此,“关键”词是向您的实例添加一个accessConfig,例如:

gcloud compute instances add-access-config [INSTANCE_NAME] \
--access-config-name "[ACCESS_CONFIG_NAME]" 

在示例中,有一个 --address [IP_ADDRESS] 选项来分配静态外部 IP,但正如注释所述,它是可选的。老实说,不容易找到!

关于gcloud - 谷歌CP : assign/remove ephemeral IP to an existing instance,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47536712/

相关文章:

firebase - Firestore 导入 - 导出 gCloud NOT_FOUND : Project 'projectID' does not exist

google-cloud-platform - 确定当前的 Firestore 模式

django - 如何在 Google Cloud Platform 上进行 Django 迁移?

javascript - Firestore - 通过时间戳查询不返回结果

tomcat - netty-tcnative 不适用于 Google Cloud Vision API

machine-learning - Google Cloud 上使用 GPU 的 Tensorflow

php - 如果启动计算引擎实例失败,如何得到错误

python - 适用于 Mac 的 Gcloud sdk 安装

google-app-engine - 如何修复 "` 必须为自定义运行时设置 --custom_entrypoint 标志?

google-cloud-platform - 如何将 Cloud SQL prod 数据库与另一个 Cloud SQL 临时数据库同步?