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

Can someone tell me how to deploy a docker image build with kaniko on gcloud kubernetes cluster using .git-ci.yml file?

谁能告诉我在 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:

这里有一些文章提供了有关如何编写“stage:deploy”部分的示例。它们可以用作整个过程的进一步指导。可以参考部署部分。

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

此致,

[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