kubectl deployment failing

耗尽温柔 提交于 2020-02-06 09:31:35

问题


I am working on setting up CI CD pipeline for Spring boot application on GKE. The CI build step worked correctly but the delivery build step is failing due to 'error: no objects passed to apply' error. I could see below logs in the cloud build

Starting Step #0 - "Deploy"
Step #0 - "Deploy": Already have image (with digest): gcr.io/cloud-builders/kubectl
Step #0 - "Deploy": Running: gcloud container clusters get-credentials --project="location-finder-kubernetes" --zone="us-central1-b" "location-finder"
Step #0 - "Deploy": Fetching cluster endpoint and auth data.
Step #0 - "Deploy": kubeconfig entry generated for location-finder.
Step #0 - "Deploy": Running: kubectl apply -f kubernetes.yaml
Step #0 - "Deploy": error: no objects passed to apply
Finished Step #0 - "Deploy"
ERROR
ERROR: build step 0 "gcr.io/cloud-builders/kubectl" failed: exit status 1

where location-finder is the name of the cluster.

To set up this pipeline, I followed all the guidelines mentioned at https://cloud.google.com/kubernetes-engine/docs/tutorials/gitops-cloud-build

The cloudbuild.yaml content for this failing step is

steps:
- name: 'gcr.io/cloud-builders/kubectl'
  id: Deploy
  args:
  - 'apply'
  - '-f'
  - 'kubernetes.yaml'
  env:
  - 'CLOUDSDK_COMPUTE_ZONE=us-central1-b'
  - 'CLOUDSDK_CONTAINER_CLUSTER=location-finder'

Kubectl version:

kubectl version
Client Version: version.Info{Major:"1", Minor:"11+", GitVersion:"v1.11.9-dispatcher", GitCommit:"e3f5193e8f1091a162af7e17a781e6a3129bcfd0", GitTreeState:"clean", BuildDate:"2019-03-28T18:13:46Z", GoVersion:"go1.10.8", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"11+", GitVersion:"v1.11.8-gke.6", GitCommit:"394ee507d00f15a63cef577a14026096c310698e", GitTreeState:"clean", BuildDate:"2019-03-30T19:31:43Z", GoVersion:"go1.10.8b4", Compiler:"gc", Platform:"linux/amd64"}

Am I missing any configuration?


回答1:


Most likely the objects are not defined correctly in the kubernetes.yaml file.

Please check the file and verify that you are able to manually deploy it. If it works then the same should work from continuous delivery.




回答2:


To test, I ran the same kubectl apply -f kubernetes.yaml, but passed an empty yaml file and got the same error as you. Is there anyting acutally in your yaml file?




回答3:


I am too facing the same issue, refering the Google Docs for CI/CD on GKE.

have you got the solution for the same ?

BUILD Starting Step #0 - "Deploy"
Step #0 - "Deploy": Already have image (with digest): gcr.io/cloud-builders/kubectl
Step #0 - "Deploy": Running: gcloud container clusters get-credentials --project="amcartecom" --zone="us-central1-b" "hello-cloudbuild"
Step #0 - "Deploy": Fetching cluster endpoint and auth data.
Step #0 - "Deploy": kubeconfig entry generated for hello-cloudbuild.
Step #0 - "Deploy": Running: kubectl apply -f kubernetes.yaml
Step #0 - "Deploy": error: no objects passed to apply
Finished Step #0 - "Deploy"
ERROR
ERROR: build step 0 "gcr.io/cloud-builders/kubectl" failed: exit status 1


来源:https://stackoverflow.com/questions/55791485/kubectl-deployment-failing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!