如何使用Kubernetes和Gitlab CI / CD在Google Cloud Platform中部署分段?

我最近和DockerKubernetesGoogle Cloud Platform(GCP)Gitlab CI/CDcommitstaging 。 到目前为止,我已经成功地testingbuilding并将映像pushing送到Container registry of Gitlab

我有一个小节点和docker应用程序输出'Hello world' 。 另外,我已经在Container registry of Gitlab构build了我Container registry of Gitlab 。 在这个时候,这个过程就是docker工人。 我想将我的图像从Gitlab container registryKubernetes engine GCP中的Kubernetes engine 。 我已经安装了kubectlgcloud sdk 。 自动DevOps似乎很有前途,但我想实现我自己的.gitlab-ci.yml文件。

这是我的.gitlab-ci.yml下面:

 stages: - testing - build - staging variables: CONTAINER_TEST_IMAGE: registry.gitlab.com/surajneupane55/node-app- testing CONTAINER_RELEASE_IMAGE: registry.gitlab.com/surajneupane55/node- app-testing:latest test: stage: testing image: node:boron script: - npm install - npm test build_image: stage: build only: [master] image: docker:git services: - docker:dind script: - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN registry.gitlab.com/surajneupane55 - docker build -t $CONTAINER_TEST_IMAGE . - docker push $CONTAINER_TEST_IMAGE staging_site: //I need help here!!! //For staging my project in Kubernetes cluster in GCP //Already created node-app Kubernetes cluster 

请让我知道,如果我的方法是错误的,因为这是我的第一个与CI / CD的学习项目。

Yu不需要图像实际存储在GCR中就可以在你的GKE中使用它,虽然附近它是好的。 你需要在gcloud上的服务帐户,以便你有一个非过期的身份validation到GCR(或者你需要使用gcloud cli身份validation到GCR),然后只是标记图像,并推动它。

在kubernetes上运行它是一个不同的故事,我强烈要求您也看看Helm为您的应用程序创build安装图表,以便在多个环境中重复使用。