在 GKE / Kubernetes 中构建、推送和测试 Docker 图像的工作流
Workflow for building, pushing, and testing Docker images inside GKE / Kubernetes
我正在开发 Kubernetes 服务以部署在 Google 容器引擎 (GKE) 中。直到最近,我还在 Google Cloud Shell 中构建了 Docker 图像,但我现在达到了配额限制,因为运行 Cloud Shell 的免费 VM 实例的整体负载从多个 docker build
s 和 push
es 来看显然太高了。到目前为止,我的经验是,经过大约一周左右的持续工作后,我面临以下 error message 并且必须等待大约两天才能再次使用 Cloud Shell。
Service usage limits temporarily exceeded. Try connecting later.
我已经尝试将我的 docker build
和 push
转移到计费机器(GCE VM 实例或 GKE 集群节点)上,但没有成功:
在 GCE VM 实例上,显然未安装 Docker。 (也有道理。)
在 GKE 集群节点上,安装了 Docker,我可以 (sudo
) docker build
我的图像,但是 docker push
(即使在gcloud docker
) 几秒后(推几层后)失败并显示以下 error message:denied: Access denied
那么 GKE 中 docker 图像的可持续发展工作流程是什么?我应该在 VM 实例上安装 Docker 吗(我希望不是),或者我希望在其他什么地方 docker build
、docker push
并最终 kubectl create
我的服务没有 运行 进入停工配额限制等? (我正在使用 MacBook 作为本地开发机器,如果可以的话,我也不希望在那里安装 Docker。也就是说,我更喜欢在云中构建 docker 图像。)
UPDATE 如果我如下为 VM 实例配备 Container-VM image,docker build
成功,但 docker push
失败之前的 GKE 集群节点(denied: Access denied
):
gcloud compute images list \
--project google-containers \
--no-standard-images
gcloud compute instances create tmp \
--machine-type g1-small
--image container-vm-v20160321 \
--image-project google-containers
--zone europe-west1-d
solution 包括将范围 storage-rw
添加到实例(否则 storage-r
默认应用):
gcloud compute images list \
--project google-containers \
--no-standard-images
gcloud compute instances create tmp \
--machine-type g1-small \
--image container-vm-v20160321 \
--image-project google-containers \
--zone europe-west1-d \
--scopes compute-rw,storage-rw
此外,我还必须安装kubectl
(like so) and configure it (like so),所以总的来说还是比较麻烦的。 (当集群的端点发生变化时,例如重新创建后,配置也必须更新。)
但我现在可以使用专用 VM 实例(例如 tmp
)进行 Docker 图像的开发工作。
UPDATE 添加范围 compute-rw
,这是必要的,例如用于操作 GCE 地址(例如 gcloud compute addresses list
)。
我正在开发 Kubernetes 服务以部署在 Google 容器引擎 (GKE) 中。直到最近,我还在 Google Cloud Shell 中构建了 Docker 图像,但我现在达到了配额限制,因为运行 Cloud Shell 的免费 VM 实例的整体负载从多个 docker build
s 和 push
es 来看显然太高了。到目前为止,我的经验是,经过大约一周左右的持续工作后,我面临以下 error message 并且必须等待大约两天才能再次使用 Cloud Shell。
Service usage limits temporarily exceeded. Try connecting later.
我已经尝试将我的 docker build
和 push
转移到计费机器(GCE VM 实例或 GKE 集群节点)上,但没有成功:
在 GCE VM 实例上,显然未安装 Docker。 (也有道理。)
在 GKE 集群节点上,安装了 Docker,我可以 (
sudo
)docker build
我的图像,但是docker push
(即使在gcloud docker
) 几秒后(推几层后)失败并显示以下 error message:denied: Access denied
那么 GKE 中 docker 图像的可持续发展工作流程是什么?我应该在 VM 实例上安装 Docker 吗(我希望不是),或者我希望在其他什么地方 docker build
、docker push
并最终 kubectl create
我的服务没有 运行 进入停工配额限制等? (我正在使用 MacBook 作为本地开发机器,如果可以的话,我也不希望在那里安装 Docker。也就是说,我更喜欢在云中构建 docker 图像。)
UPDATE 如果我如下为 VM 实例配备 Container-VM image,docker build
成功,但 docker push
失败之前的 GKE 集群节点(denied: Access denied
):
gcloud compute images list \
--project google-containers \
--no-standard-images
gcloud compute instances create tmp \
--machine-type g1-small
--image container-vm-v20160321 \
--image-project google-containers
--zone europe-west1-d
solution 包括将范围 storage-rw
添加到实例(否则 storage-r
默认应用):
gcloud compute images list \
--project google-containers \
--no-standard-images
gcloud compute instances create tmp \
--machine-type g1-small \
--image container-vm-v20160321 \
--image-project google-containers \
--zone europe-west1-d \
--scopes compute-rw,storage-rw
此外,我还必须安装kubectl
(like so) and configure it (like so),所以总的来说还是比较麻烦的。 (当集群的端点发生变化时,例如重新创建后,配置也必须更新。)
但我现在可以使用专用 VM 实例(例如 tmp
)进行 Docker 图像的开发工作。
UPDATE 添加范围 compute-rw
,这是必要的,例如用于操作 GCE 地址(例如 gcloud compute addresses list
)。