[英]How to create GCP Instance-Template with accessConfig using gcloud command
希望這不是太偶然,所以有人可以提供幫助。
我喜歡在運行此命令時使用 create 命令創建實例模板:
gcloud compute instance-templates create jenkins-slave-instance-template-tmp1 --network-interface=network=default,network-tier=PREMIUM...
。
我以這種方式獲得 networkInterfaces(使用 describe 命令):
networkInterfaces:
- kind: compute#networkInterface
name: nic0
network:
https://www.googleapis.com/compute/v1/projects/*******/global/networks/default
但是在使用 GCP UI 控制台創建時,我得到了它(因為我實際上需要它):
networkInterfaces:
- accessConfigs:
- kind: compute#accessConfig
name: External NAT
networkTier: PREMIUM
type: ONE_TO_ONE_NAT
kind: compute#networkInterface
name: nic0
network: https://www.googleapis.com/compute/v1/projects/*******/global/networks/default
如何在創建時為實例模板添加 accessConfig(我可以從 UI 執行相同操作,但等效的 gcloud compute instance-templates create 在沒有 accessConfig 條目的情況下創建它。
感謝您的幫助
您可以使用帶有默認參數的instance-templates create
命令在 gcloud cli 中創建實例模板。
gcloud compute instance-templates create INSTANCE_TEMPLATE_NAME
如果您不提供顯式模板配置/屬性,gcloud compute 使用以下默認值。
如果您運行gcloud compute instance-templates describe INSTANCE_TEMPLATE_NAME
命令,您將在網絡接口參數中獲得accessConfigs
。
您可以通過 gcloud cli 指定它們,但是如果您想要accessConfigs
參數,那么您應該在運行 instance-template 時省略網絡接口參數(--network-interface=network=default,network-tier=PREMIUM,nic-type=GVNIC)
命令。
例如:
gcloud compute instance-templates create example-template-1 --machine-type=e2-standard-4 --image-family=debian-10 --image-project=debian-cloud --boot-disk-size=250GB
上面的命令將使用提到的配置創建實例模板,並為你提供accessConfigs
參數,因為你沒有提到網絡接口參數。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.