Google Associate Cloud EngineerEnsuring successful operation of a cloud solutionMedium
A development team is using Cloud Build to automate their CI/CD pipeline. They need to ensure that every successful build automatically deploys the new container image to a Google Kubernetes Engine (GKE) cluster. Which Cloud Build feature should be used to trigger this deployment after a successful build step?
- ACloud Build triggers with manual invocation
- BA custom Cloud Build step using `kubectl apply` or `kubectl set image`
- CCloud Build webhooks for external services
- DA custom Cloud Build step using `gcloud container clusters get-credentials`
Show answer & explanationAnswer & explanation
Correct answer: B. A custom Cloud Build step using `kubectl apply` or `kubectl set image`
After a container image is built and pushed to Container Registry or Artifact Registry, a subsequent Cloud Build step can use `kubectl` commands to deploy the new image to a GKE cluster. This is done within a custom Cloud Build step that has access to the GKE cluster.
Why the other options are wrong
- A. Manual invocation requires a user to start the build, which doesn't align with automated deployment after a successful build.
- C. Cloud Build webhooks are for triggering external services from Cloud Build, not for deploying to GKE directly from within the build itself.
- D. `gcloud container clusters get-credentials` is used to configure `kubectl` locally, but the actual deployment command is missing. This step alone does not deploy.
Cloud Build Custom Steps
Cloud Build allows defining custom build steps using any container image, enabling execution of arbitrary commands within the build process.
- Each step runs in its own container.
- Steps can share data using a shared workspace volume.
- Commonly used for deploying to GKE, running tests, or custom scripting.
Memory trick: Build, Push, then Kube Deploy.