繁体   English   中英

云构建部署到 gke 集群

[英]cloud build deploy into gke cluster

我正在使用Google CLoud BuildCloud 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"

但是我已经在cloudbuild.yaml文件中输入了cluster namezone

以下是集群信息

 $ 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=

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM