Google云端的glcoud计算实例创建错误"未找到资源项目/ {ourID} / global / images / family / debian-8

时间:2017-07-24 11:58:29

标签: command-line google-cloud-platform

我们正在使用我在 Google Cloud Platform 上创建的服务器来创建和管理其他服务器。但是当尝试使用GCloud计算实例创建函数从Linux命令行创建新服务器时,我们收到以下错误:

marco@ans-mgmt-01:~/gcloud$ ./create_gcloud_instance.sh app-tst-04 tst,backend-server,bootstrap home-tst 10.20.22.104
ERROR: (gcloud.compute.instances.create) Could not fetch resource:
- The resource 'projects/REMOVED_OUR_PROJECTID/global/images/family/debian-8' was not found

我们的脚本如下所示:

#!/bin/bash                                                                                                                                                                                                                                                                    
if [ "$#" -ne 4 ]; then                                                                                                                                                                                                                                                        
    echo "Usage: create_gcloud_instance <instance_name> <tags> <subnet_name> <server_ip>"                                                                                                                                                                                                                
    exit 1
fi

set -e

INSTANCE_NAME=$1
TAGS=$2
SERVER_SUBNET=$3
SERVER_IP=$4

gcloud compute --project "REMOVED OUR PROJECT ID" instances create "$INSTANCE_NAME" \
    --zone "europe-west1-c" \
    --machine-type "f1-micro" \
    --network "cloudnet" \
    --subnet "$SERVER_SUBNET" \
    --no-address \
    --private-network-ip="$SERVER_IP" \
    --maintenance-policy "MIGRATE" \
    --scopes "https://www.googleapis.com/auth/devstorage.read_only","https://www.googleapis.com/auth/logging.write","https://www.googleapis.com/auth/monitoring.write","https://www.googleapis.com/auth/servicecontrol","https://www.googleapis.com/auth/service.management.readonly","https://www.googleapis.com/auth/trace.append" \
    --service-account "default" \
    --tags "$TAGS" \
    --image-family "debian-8" \
    --boot-disk-size "10" \
    --boot-disk-type "pd-ssd" \
    --boot-disk-device-name "bootdisk-$INSTANCE_NAME" \


./clean_known_hosts.sh $INSTANCE_NAME

在google云控制台(console.cloud.google.com)上,我为ans-mgmt-01服务器启用了云api访问范围,并尝试从那里创建服务器。这没有问题。

1 个答案:

答案 0 :(得分:7)

问题是gcloud正在寻找项目中的图像系列,而不是它真正存在的debian-cloud项目。

只需使用--image-project debian-cloud即可解决此问题。

这样,它就会寻找projects/{yourID}/global/images/family/debian-8

,而不是寻找projects/debian-cloud/global/images/family/debian-8