如何解决云构建部署到 gke 集群
我正在使用 Google CLoud Build
将图像从 Cloud repository
部署到 GKE CLuster
我试图在 cloudbuild.yaml
中添加的命令如下
kubectl run hello-app --image='gcr.io/<project>/hello-app'
为此,我在 cloudbuild.yaml
文件中添加了以下条目
steps:
- name: 'gcr.io/cloud-builders/kubectl'
args: ['run','build-image','image=my-container=gcr.io/<project>/hello-app']
env:
- 'CLOUDSDK_COMPUTE_ZONE=europe-west4-a'
- 'CLOUDSDK_CONTAINER_CLUSTER=cluster-111-poc'
但它因以下错误而失败
Running: gcloud container clusters get-credentials --project="<project>" --zone="europe-west4-a" "cluster-111-poc"
Fetching cluster endpoint and auth data.
kubeconfig entry generated for cluster-111-poc.
.....
....
BUILD
Starting Step #0
Step #0: Already have image (with digest): gcr.io/cloud-builders/kubectl
Step #0: No cluster is set. To set the cluster (and the region/zone where it is found),set the environment variables
Step #0: CLOUDSDK_COMPUTE_REGION=<cluster region> (regional clusters)
Step #0: CLOUDSDK_COMPUTE_ZONE=<cluster zone>
Step #0: CLOUDSDK_CONTAINER_CLUSTER=<cluster name>
Step #0:
Step #0: Optionally,you can specify the kubectl version via KUBECTL_VERSION,taking one of the following values: 1.14 1.15 1.16 1.17 1.18
Finished Step #0
ERROR
ERROR: build step 0 "gcr.io/cloud-builders/kubectl" failed: step exited with non-zero status: 1
ERROR: (gcloud.builds.submit) build 3eec2f29-ba4e-4b0e-82cb-16f90f43fbd4 completed with status "FAILURE"
但我已经在 cluster name
文件中输入了 zone
和 cloudbuild.yaml
下面是集群信息
$ gcloud container clusters list
NAME LOCATION MASTER_VERSION MASTER_IP MACHINE_TYPE NODE_VERSION NUM_NODES STATUS
cluster-111-poc europe-west4-a 1.16.15-gke.4901 X.X.X.142 e2-medium 1.16.15-gke.4901 3 RUNNING
请推荐
解决方法
需要设置CLUSTER_NAME、COMPUTE_ZONE、PROJECT_NAME等环境
CLOUDSDK_COMPUTE_REGION= CLOUDSDK_COMPUTE_ZONE= CLOUDSDK_CONTAINER_CLUSTER=
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。