我在Gitlab CI管道中收到以下错误消息,但我无法采取任何措施。昨天管道仍然有效,但是我没有更改yml中的任何内容,也不知道在哪里犯了错误。我也将代码重置为上次工作的提交,但仍然发生错误。

$ kubectl set image deployment/ft-backend ft-backend=registry.gitlab.com/projectX/ft-backend



.gitlab-ci.yml
image: docker:latest
services:
  - docker:dind

variables:
  DOCKER_DRIVER: overlay
  SPRING_PROFILES_ACTIVE: gitlab-ci

stages:
  - build
  - package
  - deploy

maven-build:
  image: maven:3-jdk-8
  stage: build
  script: "mvn package -B"
  artifacts:
    paths:
      - target/*.jar

docker-build:
  stage: package
  script:
  - docker build -t registry.gitlab.com/projectX/ft-backend:${CI_COMMIT_SHA} .
  - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN registry.gitlab.com
  - docker push registry.gitlab.com/projectX/ft-backend:${CI_COMMIT_SHA}

k8s-deploy:
  image: google/cloud-sdk
  stage: deploy
  script:
  - echo "$GOOGLE_KEY" > key.json
  - gcloud auth activate-service-account --key-file key.json
  - gcloud config set compute/zone europe-west3-a
  - gcloud config set project projectX
  - gcloud config unset container/use_client_certificate
  - gcloud container clusters get-credentials development --zone europe-west3-a --project projectX
  - kubectl delete secret registry.gitlab.com
  - kubectl create secret docker-registry registry.gitlab.com --docker-server=https://registry.gitlab.com --docker-username=MY_NAME --docker-password=$REGISTRY_PASSWD --docker-email=MY_MAIL
  - kubectl set image deployment/ft-backend ft-backend=registry.gitlab.com/projectX/ft-backend:${CI_COMMIT_SHA}
  - kubectl apply -f deployment.yml

最佳答案

我想当您调用命令时:
kubectl set image deployment/ft-backend ft-backend=registry.gitlab.com/projectX/ft-backend
群集中不存在部署ft-backend。命令kubectl get deployment ft-backend是否返回相同的结果?

关于docker - 找不到Kubernetes部署。扩展,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/53602658/

10-09 06:49