Reputation: 864
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?
Upvotes: 8
Views: 26138
Reputation: 4729
This error comes when we have any spelling or spacing issues in your deployment/config file. There is no other reason why this is not working.
To check if your system configurations are fine. you can use below file to check if system configurations are fine in your system. If both the below steps are working fine then your Kubernetes configurations are perfect. Just check the spelling or spacing issues. and your file is saved properly with .yaml extention
Step 1: Try to check if your Kubernetes is running properly or not using kubectl version
command. You must see something like this, it means your Kubernetes is running properly:
Step 2: Use this basic file to create the Pod. It must create a Pod.
Note: In image:, put your image path
app-depl.yaml file code:
apiVersion: apps/v1
kind: Deployment
metadata:
name: app-depl
spec:
replicas: 1
selector:
matchLabels:
app: users
template:
metadata:
labels:
app: users
spec:
containers:
- name: posts
image: image sha256:ced8014b9cddb9ca4c81ced8ced801ced80175ab445cced801
Upvotes: 0
Reputation: 19
Make sure saving the file, bacause it happened with me and I took few minutes to notice it: I started with touch deploydescriptor.yaml
, opened file in vscode and started mentioning yaml configuration for deployment but never saved it and it started giving error: no objects passed to apply
when I executed kubectl apply -f deploydescriptor.yaml
Upvotes: 2
Reputation: 1034
Check whether Visual Studio Code Auto-save is disabled and you have not saved your file. Drove me nuts and realized, the error is exactly what it means.
Upvotes: 2
Reputation: 1
please check if you have entered namespace in yaml file. This worked for me.
Upvotes: 0
Reputation: 855
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
Upvotes: 0
Reputation: 942
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?
Upvotes: 15
Reputation: 17689
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.
Upvotes: 2