【发布时间】:2017-11-10 16:18:11
【问题描述】:
我使用服务帐户创建一个 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"
通过 ssh 登录到实例:gcloud compute --project "myproj" ssh --zone "europe-west1-b" "gitlab-shared-runner-pool"
安装和配置 docker 机器后。我尝试创建实例:
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
谁能解释一下,我做错了什么?
【问题讨论】:
-
我使用的是 0.12 版本的 docker 机器。 0.13版本不行,总是返回segmentation failed。
-
我看到 $GOOGLE_APPLICATION_CREDENTIALS 是空的。我不明白,gcloud 凭据存储在哪里
-
完整的脚本可以在这里找到github.com/GrigorievNick/gitlab-runner-gce
标签: docker docker-machine google-compute-engine