Kubernetes deployment.extensions not found

18,037

Solution 1

I suppose that when you are invoking command:

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

deployment ft-backend does not exist in your cluster. Does the command: kubectl get deployment ft-backend return the same result?

Solution 2

Use this command to create deployments, its not supported in newer version: check this for newer version:

$ kubectl create deployment hello-minikube --image=k8s.gcr.io/echoserver:1.4
Share:
18,037

Related videos on Youtube

laprof
Author by

laprof

Updated on June 03, 2022

Comments

  • laprof
    laprof almost 2 years

    I get the following error message in my Gitlab CI pipeline and I can't do anything with it. Yesterday the pipeline still worked, but I didn't change anything in the yml and I don't know where I made the mistake. I also reset my code to the last working commit, but the error still occurs.

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

    Error from server (NotFound): deployments.extensions "ft-backend" not found

    .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
    
    • laprof
      laprof over 5 years
      I just removed - kubectl set image deployment/ft-backend ft-backend=registry.gitlab.com/projectX/ft-backend:${CI_COMM‌​IT_SHA} for the first build, run the code without :${CI_COMMIT_SHA} tags and added everything everything back for next builds.
    • Feckmore
      Feckmore over 4 years
      In my case, when getting this error while using the circleci orb job "kubernetes/create-or-update-resource" i needed to specify the namespace for the job that was specified in the deployment manifest.
  • Tara Prasad Gurung
    Tara Prasad Gurung over 4 years
    I had a same issue and it was simply a mismatched deployment name