Kubernetes kubectl部署失败

Kubernetes kubectl部署失败,kubernetes,kubectl,Kubernetes,Kubectl,我正在为GKE上的Spring boot应用程序设置CI CD管道。CI生成步骤工作正常,但传递生成步骤由于“错误:未传递要应用的对象”错误而失败。我可以在云构建中看到下面的日志 Starting Step #0 - "Deploy" Step #0 - "Deploy": Already have image (with digest): gcr.io/cloud-builders/kubectl Step #0 - "Deploy": Running: gcloud container cl

我正在为GKE上的Spring boot应用程序设置CI CD管道。CI生成步骤工作正常,但传递生成步骤由于“错误:未传递要应用的对象”错误而失败。我可以在云构建中看到下面的日志

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是群集的名称

为了建立这个管道,我遵循了在

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

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
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
文件中没有正确定义对象


请检查该文件并验证您是否能够手动部署它。如果它能工作,那么在连续交付中也能工作。

为了测试,我运行了相同的
kubectl apply-f kubernetes.yaml
,但传递了一个空的yaml文件,并得到了与您相同的错误。你的yaml文件里有什么确切的信息吗

我也面临同样的问题,在GKE上为CI/CD引用谷歌文档

你有同样的解决办法吗

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

您好,Swapnil,您可以发布
kubernetes.yaml
文件吗?按照文档中提到的步骤,有一个名为kubectl.yaml.tpl的模板文件。使用此文件,自动化过程将创建最终的kubernetes.yaml文件。忘记将模板文件添加到源代码管理是我的错误@阿尔斯兰贝科夫,你要的是同一份文件,这给了我一个解决问题的暗示。谢谢回复!是的,这个文件不应该是空的。参考文档,按原样使用。只需将集群名称替换为您的集群名称。哈哈。我以“touch my.yaml”开始文件。在VSCode中提出,添加了一堆东西,但从未保存过!!一个“无聊”的时刻。