cloudbuild.yaml to:
- Build the Docker image
- Push it to Google Container Registry (GCR)
- Deploy to a GKE cluster with a Kubernetes manifest
Prerequisites
- A GKE cluster up and running
gcloudCLI configured with your project and zone- Cloud Build API enabled
- Service account with the following roles:
roles/container.developerroles/storage.admin
Ensure your Cloud Build service account has the Kubernetes Engine Developer and Storage Admin roles. Without these, build or deploy steps may fail.
Kubernetes Deployment Manifest
We’ve already created a Kubernetes Deployment manifest (gke.yaml) for our sample app:
Initial cloudbuild.yaml
Our startingcloudbuild.yaml only built and pushed the Docker image:
Extending cloudbuild.yaml for GKE Deployment
We’ll add a third step to invoke thegke-deploy builder, which applies our Kubernetes manifest directly to GKE:
Step-by-Step Overview
References
Next Steps
- Commit and push your updated
cloudbuild.yamlto a feature branch. - Open a pull request for review.
- Merge into
main.