如何在Google Container Engine上运行私人泊坞窗图片

如何运行我在Google Container Engine本地构build的docker图像?

您可以将图片推送到Google Container Registry ,并从您的pod清单中引用它们。

详细的说明

假设您正确设置了DOCKER_HOSTDOCKER_HOST安装运行最后一个Kubernetes版本和Google Cloud SDK的GKE群集。

  1. 设置一些环境variables

     gcloud components update kubectl gcloud config set project <your-project> gcloud config set compute/zone <your-cluster-zone> gcloud config set container/cluster <your-cluster-name> gcloud container clusters get-credentials <your-cluster-name> 
  2. 标记您的图片

     docker tag <your-image> gcr.io/<your-project>/<your-image> 
  3. 推你的形象

     gcloud docker push gcr.io/<your-project>/<your-image> 
  4. 为您的容器创build一个pod清单: my-pod.yaml

     id: my-pod kind: Pod apiVersion: v1 desiredState: manifest: containers: - name: <container-name> image: gcr.io/<your-project>/<your-image> ... 
  5. 安排这个吊舱

     kubectl create -f my-pod.yaml 
  6. 从步骤(4)重复您要运行的每个吊舱。 您可以使用以---作为分隔符的行在单个文件中包含多个定义。

您可以在启动Pod之前将私有Dockerregistry的registry身份validation密钥复制到小工具根目录中的.dockercfg文件中。 或者在开始之前运行dockerlogin。

  docker login --username=<> --password=<> --email=<> <DockerServer> 

引用podconfiguration中的私有docker映像然后应该按预期工作。

我使用的设置是部署我自己的dockerregistry结合ssh端口转发。 为此,我在集群中设置了一个ssh服务器,并使用~/.ssh/config来configuration一个转发到registry的端口。

另外我用jenkins在云中构build图像。