kubectl 部署失败

Swa*_*nil 2 kubernetes kubectl

我正在为 GKE 上的 Spring 启动应用程序设置 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
Run Code Online (Sandbox Code Playgroud)

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

为了设置这个管道,我遵循了https://cloud.google.com/kubernetes-engine/docs/tutorials/gitops-cloud-build 中提到的所有指南

此失败步骤的 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'
Run Code Online (Sandbox Code Playgroud)

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"}
Run Code Online (Sandbox Code Playgroud)

我缺少任何配置吗?

Jos*_*ant 5

为了测试,我运行了相同的kubectl apply -f kubernetes.yaml,但传递了一个空的 yaml 文件并得到了与您相同的错误。您的 yaml 文件中是否有任何内容?

  • 哈哈。我以“touch my.yaml”开始该文件。把它放在 VSCode 中,添加了一堆东西,但从未保存过!一个“呃”时刻。 (3认同)

P E*_*ram 2

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

请检查该文件并验证您是否能够手动部署它。如果它有效,那么持续交付也应该有效。