Skip to main content

Overview

We encountered a Cloud Build failure due to an incorrect GKE cluster name. In this guide, we will:
  • Identify the root cause
  • Correct the cloudbuild.yaml configuration
  • Commit and merge the fix
  • Monitor the updated build

1. Original cloudbuild.yaml

The pipeline failed because the cluster name in the gke-deploy step didn’t match the actual cluster in the console:
Always verify resource names in the Google Cloud Console. A mismatch will cause your build to fail.

2. Verify the Cluster Name

Navigate to the Kubernetes clusters section in the console. You’ll see the actual name: GCP DevOps Project.

3. Updated cloudbuild.yaml

Replace the incorrect cluster reference (gke-gcp-devops) with the correct one (gcp-devops-project) and adjust the location flag:

4. Commit and Push the Fix

Open a pull request titled Update cluster name on the minor/deployment-file branch and merge it. This triggers the Cloud Build pipeline on main.

5. Monitor the Build

After merging, you’ll see a green dot next to your repository. Click DetailsView more details on Google Cloud Build. Cloud Build will:
  1. Build the Docker image
  2. Push it to Container Registry
  3. Deploy to the GKE cluster with the corrected name
If the specified namespace (gcp-devops-prod) doesn’t exist, the deployment will fail at the gke-deploy step. Ensure namespaces are created in advance.
The image shows a Google Cloud Build interface with a successful build summary, detailing steps and logs for a deployment process.

6. Next Steps

The pipeline completes successfully, and your container is now running in the gcp-devops-prod namespace. In the next lesson, we’ll explore how to verify running pods from the GCP console.

Watch Video