kubectl部署失败 [英] kubectl deployment failing

查看:995
本文介绍了kubectl部署失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为GKE上的Spring Boot应用程序设置CI CD管道. CI构建步骤正常工作,但是交付构建步骤由于错误:没有传递适用对象"错误而失败.我可以在云构建中看到以下日志

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

其中location-finder是集群的名称.

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

此失败步骤的cloudbuild.yaml内容为

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版本:

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"}

我缺少任何配置吗?

推荐答案

很可能在kubernetes.yaml文件中未正确定义对象.

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.

这篇关于kubectl部署失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆