Search code examples
dockerkubernetesgoogle-cloud-build

My cloudbuild.yaml is failing. Please review my cloudbuild.yaml


I am trying to set a react app to a kubernetes cluster. All my kubernetes files resides in k8s/ folder. In k8s/ folder I have a deployment.yaml and service.yaml file.

The below is my cloudbuild.yaml file which resides in the root folder. This part gcr.io/cloud-builders/kubectl Stage 3 is failing. I get the below error

build step 2 "gcr.io/cloud-builders/kubectl" failed: step exited with non-zero status: 1
steps:

# Build the image - Stage 1
- name: 'gcr.io/cloud-builders/docker'
  args: ['build','-t','gcr.io/${_PROJECT}/${_CONTAINERNAME}:${_VERSION}','.']
  timeout: 1500s

# Push the image - Stage 2
- name: 'gcr.io/cloud-builders/docker'
  args: ['push','gcr.io/${_PROJECT}/${_CONTAINERNAME}:${_VERSION}']
  
# Deploy changes to kubernetes config files - Stage 3
- name: "gcr.io/cloud-builders/kubectl"
  args: ["apply", "-f", "k8s/"]
  env:
  - 'CLOUDSDK_COMPUTE_ZONE=${_ZONE}'
  - 'CLOUDSDK_CONTAINER_CLUSTER=${_GKE_CLUSTER}'

# These are variable substitutions  
substitutions:
    #GCP Specific configuration. Please DON'T change anything
    _PROJECT: my-projects-121212
    _ZONE: us-central1-c
    _GKE_CLUSTER: cluster-1
    
    #Repository Specific configuration. DevOps can change this settings
    _DEPLOYMENTNAME: react
    _CONTAINERNAME: react    
    _REPO_NAME: react-app
    
    # Developers ONLY change
    _VERSION: v1.0
    
options:
    substitution_option: 'ALLOW_LOOSE'
    machineType: 'N1_HIGHCPU_8' 
timeout: 2500s

Solution

  • In step 3, there are double quotes name: "gcr.io/cloud-builders/kubectl"

    If you replace them with single quotes, the issue should be fixed.