Docker-Machine不适用于Google Cloud服务帐户

我创build一个带有服务帐户的Google计算实例

gcloud --project my-proj compute instances create test1 \ --image-family "debian-9" --image-project "debian-cloud" \ --machine-type "g1-small" --network "default" --maintenance-policy "MIGRATE" \ --service-account "gke-build-robot@myproj-184015.iam.gserviceaccount.com" \ --scopes "https://www.googleapis.com/auth/cloud-platform" \ --tags "gitlab-runner" \ --boot-disk-size "10" --boot-disk-type "pd-standard" --boot-disk-device-name "$RESOURCE_NAME" \ --metadata register_token=mytoken,config_bucket=gitlab_config,runner_name=test1,gitlab_uri=myuri,runner_tags=backend \ --metadata-from-file "startup-script=startup-scripts/prepare-runner.sh" 

通过sshlogin到实例: gcloud compute --project "myproj" ssh --zone "europe-west1-b" "gitlab-shared-runner-pool"

在安装和configurationdocker机后。 我尝试创build实例:

  docker-machine create --driver google --google-project myproj test2 Running pre-create checks... (test2) Check that the project exists (test2) Check if the instance already exists Creating machine... (test2) Generating SSH Key (test2) Creating host... (test2) Opening firewall ports (test2) Creating instance (test2) Waiting for Instance Error creating machine: Error in driver during machine creation: Operation error: {EXTERNAL_RESOURCE_NOT_FOUND The resource '1045904521672-compute@developer.gserviceaccount.com' of type 'serviceAccount' was not found. []} 

1045904521672-compute@developer.gserviceaccount.com是我的默认帐户。 我不明白它为什么使用。 因为激活是gke-build-robot@myproj-184015.iam.gserviceaccount.com

 gcloud config list [core] account = gke-build-robot@myproj-184015.iam.gserviceaccount.com disable_usage_reporting = True project = novaposhta-184015 Your active configuration is: [default] gcloud auth list Credentialed Accounts ACTIVE ACCOUNT * gke-build-robot@myproj-184015.iam.gserviceaccount.com 

有人可以解释我,我做错了什么?

有双重问题。

  • 首先,docker机不能使用特定的服务帐户,至less在0.12和0.13版本。
  • Docker +机器的谷歌驱动程序只有scope参数,不能得到特定的一个。
    所以docker +机器安装的实例在指定的sa工作正常。 但是,使用docker + machine创build的实例必须具有默认的服务帐户
    而在debugging过程中,我把它关掉了。
    我得到了这个错误。

类似的问题( bosh-google-cpi-release issue 144 )暗示了某种程度上的问题

此错误消息不明确,特别是因为还需要在清单中指定的凭据可能与另一个帐户完全关联。

bosh-google-cpi-release的默认service_account被设置为“ default ”,如果它不是由bosh清单主动设置的,所以这个会在你使用service_scopes而不是service_account时候发生。

当你不使用bosh-google-cpi-release ,最后一句话让我仔细检查了gcloud引用页面 ,特别是gcloud compute instance create

服务帐户是附加到实例的标识。 其访问令牌可以通过实例元数据服务器访问,并用于对实例上的应用程序进行身份validation。
该帐户可以是电子邮件地址,也可以是与服务帐户对应的别名。 您可以使用“ default ”别名明确指定计算引擎默认服务帐户。

如果没有提供,实例将获得项目的默认服务帐户。

就好像您的服务帐户被忽略或不正确(并退回到项目默认的帐户)

请参阅“ 为实例创build和启用服务帐户 ”来仔细检查其值:

通常,服务帐户的电子邮件是从服务帐户ID导出的,格式为:

 [SERVICE-ACCOUNT-NAME]@[PROJECT_ID].iam.gserviceaccount.com 

或者先尝试设置服务范围和帐户 。