有人可以告诉我如何使用.git-ci.yml文件在gcloud kubernetes集群上部署带有kaniko的docker镜像吗?

时间:2019-09-03 16:01:12

标签: docker gitlab devops gcloud kaniko

有人可以告诉我可以在deploy: stages脚本标记中编写哪些命令来将代码推送到gcloud Kubernetes集群上吗?

build:
  stage: build
  image:
    name: gcr.io/kaniko-project/executor:debug
    entrypoint: [""]

  before_script:
    - echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
    - |
      echo "-----BEGIN CERTIFICATE-----
      ...
      -----END CERTIFICATE-----" >> /kaniko/ssl/certs/ca-certificates.crt


  script:
    - echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
    - /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
  only:
    - master


deploy:
  stage: deploy

  script:

1 个答案:

答案 0 :(得分:0)

有些文章包含有关如何编写“阶段:部署”部分的示例。它们可以用作整个过程的进一步指导。您可以参考部署部分。

  • GitLab + Kubernetes:使用GitLab CI的Kubernetes集群功能[1]。
  • 如何使用GitLab和Helm [2]通过自动部署到Kubernetes创建CI / CD管道。
  • 使用GitLab [3]自动部署到Kubernetes。
  • 使用GitLab,Helm和Traefik [4]自动进行Kubernetes部署。

此致

[1] https://edenmal.moe/post/2018/GitLab-Kubernetes-Using-GitLab-CIs-Kubernetes-Cluster-feature/#step-6-add-docker-login-information-to-kubernetes [2] https://about.gitlab.com/2017/09/21/how-to-create-ci-cd-pipeline-with-autodeploy-to-kubernetes-using-gitlab-and-helm[3] https://sanderknape.com/2019/02/automated-deployments-kubernetes-gitlab/ [4] https://medium.com/@yanick.witschi/automated-kubernetes-deployments-with-gitlab-helm-and-traefik-4e54bec47dcf

相关问题