Md Zannatul Ferdous
Md Zannatul Ferdous

Reputation: 91

Error from server (NotFound): error when creating STDIN: namespaces gitlab-runner not found

I am setting up CI CD pipeline using GitLab. The .gitlab-ci.yml file deployment section is given below.

Deploy to DEV:
  variables:
    GCP_PROJECT_ID: <>
    GOOGLE_IMAGE_NAME: <>
    CLUSTER_NAME: <>
    ZONE: <>
  image: gcr.io/cloud-builders/kubectl
  stage: deploy
  before_script:
    - curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh"  | bash
    - mv kustomize /usr/local/bin/
  script:
    - gcloud auth activate-service-account --key-file ${GOOGLE_APPLICATION_CREDENTIALS}
    - gcloud container clusters get-credentials $CLUSTER_NAME --zone $ZONE --project $GCP_PROJECT_ID
    - cd .k8s/overlays/dev
    - kustomize edit set image <IMAGE_NAME>=gcr.io/$GCP_PROJECT_ID/$GOOGLE_IMAGE_NAME:$VERSION-$CI_COMMIT_SHORT_SHA
    - kustomize build . 
    - kustomize build . | kubectl apply -f -
  only:
    refs:
      - merge_request
      - master
  when: manual

It shows the error Error from server (NotFound): error when creating STDIN: namespaces gitlab-runner not found

But I have not defined any namespaces named gitlab-runner. The cluster don't have any namespace with that name. Where is this coming from?

Upvotes: 2

Views: 6734

Answers (1)

Md Zannatul Ferdous
Md Zannatul Ferdous

Reputation: 91

For anyone who is bumping into the same or similar problem, I finally was able to solve it by explicitly mentioning the namespace: default in the Deployment yaml. I thought since the Deployment was in the Default namespace I would not have to specify the namespace. But specifying it solved it for me.

I still don't know what's causing the issue though.

Upvotes: 7

Related Questions