【问题标题】:cloud build deploy into gke cluster云构建部署到 gke 集群
【发布时间】:2021-04-14 11:03:26
【问题描述】:

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

但是我已经在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
  

请推荐

【问题讨论】:

  • 你只有这一步?
  • 是的..截至目前...这是我的第一次 Cloudbuild 试用...任何使用云构建将映像部署到 gke 的指针
  • 请检查 my answer 中的 build.yaml,如果您正在搜索,请告诉我。

标签: google-kubernetes-engine kubectl google-cloud-build


【解决方案1】:

您需要设置CLUSTER_NAME、COMPUTE_ZONE、PROJECT_NAME等环境

CLOUDSDK_COMPUTE_REGION= CLOUDSDK_COMPUTE_ZONE= CLOUDSDK_CONTAINER_CLUSTER=

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-02-25
    • 2021-04-13
    • 2020-12-16
    • 2020-04-02
    • 2020-03-25
    • 2020-01-13
    • 1970-01-01
    相关资源
    最近更新 更多