Prepare and test your skills
Prepare and test your skills
Continuous integration (CI) with Cloud Build (opens in a new tab) is the automated practice of testing every commit, building a container image, and pushing a versioned artifact to Artifact Registry. A cloudbuild.yaml file declares an ordered list of steps that share source code and a workspace, and a build trigger starts that file when a repository event occurs. Data flows from the source repository to the trigger, from the trigger through the build steps in order, and from the final steps to deployment targets.
A cloudbuild.yaml build configuration in Cloud Build defines work as an ordered sequence of steps that share the build workspace. Each step names a builder container image, a unique id, an optional entrypoint, args passed to the container, and optional env values. Data flows from the fetched source into the first step and then from step to step in declared order, so a later step can use files created by an earlier step.
The following builders divide work by tool:
| Builder image | Role in the pipeline |
|---|---|
python:3.13-slim | Run unit tests and install dependencies |
gcr.io/cloud-builders/docker | Build container images and push images to Artifact Registry |
gcr.io/cloud-builders/gcloud | Clone source repositories and generate manifests with shell commands |
gcr.io/cloud-builders/kubectl | Apply Kubernetes manifests to a Google Kubernetes Engine cluster |
gcr.io/cloud-builders/git | Fetch branches, copy manifests, and push commits between branches |
A minimal CI pipeline runs three steps in strict order:
python:3.13-slim, for example with entrypoint: /bin/sh.docker build in the Docker builder and tag the image with the commit SHA.docker push in the Docker builder to store the tagged image in Artifact Registry.An extended pipeline that connects integration to delivery adds manifest steps after the push. First a clone step checks out the candidate branch of an environment repository, then a generate step renders kubernetes.yaml from a template with the new project ID and commit SHA, and only after that a push-manifest step commits and pushes to origin candidate.
A Cloud Build trigger binds a connected source repository, an event filter, a configuration file path, substitution values, and a service account into one repeatable pipeline. Sources include Cloud Source Repositories, GitHub, GitLab, and Bitbucket, linked through Cloud Build repositories or Developer Connect connections. Only pushes that match the branch filter, such as the main branch, start a build, and the build can read the matched branch through $BRANCH_NAME.
Creating a production trigger follows an ordered workflow:
cloudbuild.yaml path, such as /cloudbuild.yaml.Testing validates the full path from source event to downstream effect. Committing and pushing cloudbuild.yaml to the monitored branch starts a build that appears in Build History, and success is confirmed when downstream systems show the expected result, such as a new workflow compilation (opens in a new tab) marked live and a new invocation in execution logs.
Substitutions in Cloud Build are variables replaced at build time that keep one cloudbuild.yaml reusable across projects and environments. Default substitutions such as $PROJECT_ID, $SHORT_SHA, and $COMMIT_SHA are replaced automatically, so the same Build and Push steps produce a correctly namespaced and uniquely tagged image on every commit. Custom substitutions start with an underscore, are declared in a substitutions: block, and are supplied by the trigger, for example $_REGION, $_AR_REPO_NAME, $_AR_IMAGE_NAME, and $_IMAGE_DIR.
Inside bash steps, references use $$ escaping such as $${_PROJECT_ID} so Cloud Build substitutes first and bash expands second. Tagging with the short commit SHA ties each stored image to the exact commit that produced it, such as us-central1-docker.pkg.dev/$PROJECT_ID/my-repository/hello-cloudbuild:$SHORT_SHA. That tag becomes the traceable link written into Kubernetes manifests for deployment.
Exam tip: A build trigger ignores the service account specified inside the build config file and uses the trigger's service account, so grant push, deploy, and repository-write roles to the trigger identity.
Build artifacts in Cloud Build are the versioned outputs kept for deployment, and container images are stored in Artifact Registry repositories. The image path encodes region, project, repository, image, and tag, and distribution depends on identity: the Cloud Build service account needs roles/artifactregistry.writer to push. User-specified service accounts limit each build to only needed roles but must store build logs (opens in a new tab) in Cloud Logging or a user-created bucket, not the default logs bucket.
Security is built into the CI path from artifact to deployment. Artifact Analysis scans images stored in Artifact Registry and shows Supply-chain Levels for Software Artifacts (SLSA) level, vulnerabilities, Vulnerability Exploitability eXchange (VEX) status, software bill of materials (SBOM), and build details in the Security insights panel. Binary Authorization then blocks deployment unless a Cloud Key Management Service (Cloud KMS)-signed attestation proves policy checks passed, while Terraform changes can be validated against organization policy before resources change.
Continue with this study guide: Continuous integration (CI) with Cloud Build
Continuous delivery (CD) with Cloud Deploy is the automated progression of one versioned release through an ordered series of deployment targets. Cloud Deploy owns the delivery pipeline and promotion order, while Skaffold renders Kubernetes manifests and applies them, and Kustomize customizes shared manifests per environment. A release binds a rendering source and container images together, and each promotion creates a rollout to the next target.
Two-stage rendering in Cloud Deploy separates manifest generation from image injection. First, Kustomize generates the hydrated Kubernetes manifest from a kustomization.yaml file and its referenced resources. Then Skaffold substitutes image references in that generated manifest with the release images supplied at release creation, for example through --images=my-app-image=gcr.io/...@sha256:....
Cloud Deploy orchestrates this work through Cloud Build at release creation. The rendering source and image references are passed to Cloud Deploy, Cloud Build runs skaffold diagnose and skaffold render to produce a rendered manifest for every target profile before the first rollout, and Cloud Deploy later calls skaffold apply to apply the already-rendered manifest to each Google Kubernetes Engine (GKE) cluster. Because all targets are rendered up front, the full state can be reviewed, approved, and reapplied safely for rollbacks.
Kustomize configuration in skaffold.yaml tells Skaffold where to find the Kustomization to render. A Kustomize entry lives under the manifests stanza and points to directories containing a kustomization.yaml file, defaulting to ["."] when no path is set. Kustomize files can live locally or in Cloud Storage, and Artifact Registry can store artifacts such as Kustomizations.
Skaffold profiles are named variants inside one skaffold.yaml that select different rendering inputs for different targets. Each target that uses Kustomize gets its own profile with its own manifests.kustomize.paths value, such as environments/staging versus environments/prod. The delivery pipeline joins rendering to progression by listing profile names on each stage:
serialPipeline:
stages:
- targetId: staging-target
profiles:
- staging
- targetId: prod-target
profiles:
- prod
When the profile name on the stage matches the profile name in skaffold.yaml, Cloud Deploy renders that stage with that stage's Kustomization. This separation lets teams change overlays without editing pipeline progression.
The Cloud Deploy release flow carries CI output to cluster state through distinct Skaffold commands. Rendering happens for all targets at release creation, so approvers can inspect the exact YAML for each target before the first rollout.
skaffold.yaml plus --images mappings to Cloud Deploy.skaffold diagnose to validate and skaffold render to hydrate manifests.skaffold apply with kubectl as the deployer.Skaffold health checks run during deployment, and Cloud Deploy uses their results to determine rollout health. Cloud Deploy supports only kubectl as the deployer for standard targets, although Helm, Kustomize, and kpt can be used as renderers and custom targets can implement alternative logic.
Strategy is the per-stage pipeline setting that controls how a rollout places the new version onto a target. If strategy is omitted, Cloud Deploy uses the standard strategy, which deploys fully in one step.
| Strategy | Deployment unit | Choose when |
|---|---|---|
| Standard | Full release to one target | The target should receive the entire new version at once |
| Automated canary | Percentage phases from canaryDeployment.percentages | Traffic must shift gradually using built-in traffic control |
| Custom canary | Named phases with per-phase percent, profiles, verify, and analysis | Each phase needs different manifests or distinct verification, ending with stable at 100% |
Canary traffic splitting depends on the runtime. Cloud Run uses automatic traffic control, GKE service networking names an existing service and deployment, and GKE Gateway API names httpRoute, service, and deployment. Deployment verification runs immediately after the deploy job, while deploy analysis evaluates observability alerts over time. Predeploy hooks run before deploy and postdeploy hooks run after verify and analysis, so staging can use light checks while production uses canary phases and longer analysis.
Exam tip: Kustomize and Helm are renderers in Cloud Deploy, not deployers; Skaffold renders with those tools and always applies with kubectl unless custom targets are used.
Artifact Registry configuration is the design of format-specific repositories, access controls, lifecycle rules, and locations for container images and language packages. Each repository holds one format, such as Docker, Maven, npm, Python, Go, Helm, Apt, or Yum, and each repository uses a mode that controls whether it stores private artifacts, caches public artifacts, or forwards requests. Consumers such as Cloud Build, GKE, and Cloud Run benefit when retention and placement match their deployment pattern.
Repository modes in Artifact Registry (opens in a new tab) separate private storage, public caching, and consolidated access by how requests flow through them:
| Mode | What it stores | Choose when |
|---|---|---|
| Standard repository | Private artifacts uploaded by builds | The team needs to publish first-party code in CI/CD |
| Remote repository | Cached copies from an external source such as Docker Hub, Maven Central, or PyPI | Builds need public dependencies with faster downloads and scanning |
| Virtual repository | No artifacts directly; forwards to upstream repositories in priority order | Clients should use one URL with controlled search order |
A standard repository depends on publishers such as Cloud Build to upload versions, while a remote repository depends on its external source on first request and then serves later requests from cache. A virtual repository depends on its upstreams, forwarding each client request in order until a match is found. Prioritizing the private standard repository above the remote repository reduces dependency confusion attacks, where an attacker publishes a higher-version public package with the same name.
Security in Artifact Registry combines identity, network, sourcing, scanning, and admission controls where artifacts are stored and requested. IAM permissions can be granted at the project level or narrowed to specific repositories, with build accounts receiving write access and runtime workloads receiving read-only access. Cross-project pulls require an explicit grant, such as granting the GKE node service account roles/artifactregistry.reader in the registry project.
Network isolation places a VPC Service Controls perimeter between trusted services inside the boundary, such as Cloud Build, GKE, and Cloud Run, and untrusted callers outside. Builds, pulls, and pushes inside the perimeter succeed, while outside requests are denied even with valid IAM credentials. An organization policy with a resource locations constraint further allows repository creation only in approved regions for data residency.
Continuous vulnerability detection with Artifact Analysis (opens in a new tab) finds issues in stored artifacts through on-demand scans and automated scans on upload. The initial scan extracts system and language package inventory, and continuous monitoring keeps results current as new intelligence arrives by updating metadata, creating new occurrences, and deleting occurrences that are no longer valid. Teams can also generate an SBOM and upload VEX statements about exploitability.
Policy enforcement connects detection to provenance and admission. Cloud Build can produce SLSA Level 3 builds with non-falsifiable provenance recording digests, source locations, toolchain, steps, and duration. Binary Authorization then checks attestations before an image runs on GKE or Cloud Run, verifying the build system, vulnerability policy compliance, or promotion from development to quality assurance. Only images with required attestations deploy, so risky images remain in the registry.
Exam tip: Artifact Analysis detects and tracks vulnerabilities in Artifact Registry, while Binary Authorization blocks deployment unless required attestations are present.
Cleanup policies in Artifact Registry are named rules that automatically delete or preserve versions. Each policy has an id and an action of DELETE or KEEP, and policies can run in dry-run mode to audit impact before enforcement. Common conditions filter by tag state (tagged, untagged, any), tag prefix, package prefix, age since upload, and retained version count. A typical CI/CD pattern combines a DELETE rule for old development versions with KEEP rules for release prefixes or the newest N versions.
Repository location balances latency, availability, cost, and compliance. Placing the repository in the same region as GKE, Cloud Run, and Cloud Build reduces pull latency and avoids egress charges, since same-region egress to Google Cloud services has no charge. Multi-region to region egress is free only for limited mappings, such as us to a United States region, but charged to other continents. Image streaming for GKE also requires images in the same region or a corresponding multi-region.
Continue with this study guide: Artifact Registry configuration
Third-party tooling in Google Cloud CI/CD combines Git as the source of truth, an automation engine to build and test changes, and a delivery controller to reconcile environments. Cloud Build is the native engine that runs cloudbuild.yaml steps as containers, while Jenkins is a supported alternative for teams retaining existing investments. Cloud Deploy automates promotion to GKE and Cloud Run, while Argo CD acts as a GitOps controller that watches Git desired state and reconciles live clusters toward it.
Git branch events provide the shared signals that start CI. Developers merge frequently into a shared repository, test automation runs unit and integration tests on each commit, and passing code produces versioned deployment artifacts. Both Cloud Build and Jenkins use build-time substitutions such as $COMMIT_SHA, $REPO_NAME, $BRANCH_NAME, and $BUILD_ID, and tagging images with $COMMIT_SHA links each image back to its exact commit for audit and rollback.
Cloud Build runs an ordered workflow against a repository that typically holds workflow source, Dockerfiles, tests, cloudbuild.yaml, and pipeline specifications:
/workspace in the build runtime.$COMMIT_SHA if tests pass.pipeline.json.pipeline.json and optionally run the pipeline for integration testing.Triggers can be skipped for documentation-only edits to avoid unnecessary builds. Staged promotion then advances only verified artifacts, with preproduction validation required before production converges.
Security for multi-cloud toolchains gives third-party tooling only the access it needs while proving inputs and outputs can be trusted. Least-privilege design uses unique service accounts per environment and project, separate accounts for reading versus writing artifacts, and separate accounts for managing Dataflow jobs versus running workers. Production jobs specify a user-managed worker with --serviceAccount instead of the broad Compute Engine default, tightened with IAM Conditions and just-in-time elevation. Secrets live in Secret Manager, and Identity-Aware Proxy adds context-aware access by IP and device.
Integrity controls address risks from Docker base images, operating system packages, and language libraries. Pipelines reduce substitution risk by requiring signed artifacts, maintaining trusted publisher keys, verifying signatures, and rebuilding infrastructure regularly from trusted sources. Network scope limits contain compromise by revoking unneeded write access, blocking internet egress or restricting it to an allow-list, and placing projects inside VPC Service Controls so deployed code cannot reach unauthorized APIs.
| Model | Protects | Pipeline must not |
|---|---|---|
| Bell-LaPadula | Confidentiality | Consume higher-confidentiality inputs, or write to lower-confidentiality resources |
| Biba | Integrity | Consume lower-integrity inputs, or write to higher-integrity resources |
Exam tip: Bell-LaPadula protects confidentiality by blocking flow from higher to lower confidentiality, while Biba protects integrity by blocking flow from lower to higher integrity.
Declarative configuration and immutable image creation defines infrastructure in versioned files and rebuilds images rather than patching systems. Packer automates golden machine images for Compute Engine, which are virtual disks that already contain required software, while Image Import brings existing VMDK or VHD disks into Google Cloud. kpt packages, customizes, and validates declarative Kubernetes configurations across GKE environments.
An automated image pipeline rebuilds on repository events through a custom image build pipeline (opens in a new tab) using cloudbuild.yaml and recipe files:
main after review starts the pipeline.This sequence enforces immutable infrastructure because a change produces a new image instead of modifying a running VM. For Kubernetes, Config Connector manages Google Cloud resources as Kubernetes objects, and Cluster Toolkit provides curated Terraform blueprints applied through Cloud Build. Tool choice follows responsibility: Terraform authors versioned configuration, Infrastructure Manager deploys it natively, and Terraform Cloud or Enterprise adds remote state and organizational change control.
Security of CI/CD tooling treats the pipeline itself like a production system with policy checks, gated promotions, and audited access. Cloud Logging records pipeline activity as an auditable trail, while Policy-as-Code engines check infrastructure as code before and after deployment. Prevention at check-in blocks misconfigurations early, and detection in production catches drift when policies or workloads change later.
Policy-as-Code writes compliance rules as machine-readable files and checks infrastructure automatically in the pipeline. Open Policy Agent is the general policy engine, and Policy Controller is its Kubernetes admission enforcement point that blocks noncompliant resources. Central Google Cloud guardrails surround the pipeline infrastructure: IAM authorizes who can act, Organization Policy restricts how resources can be configured, and VPC Service Controls creates service perimeters for defense in depth.
Organization policies commonly applied to CI/CD environments include:
Cloud Deploy adds human oversight through gated deployments that require explicit approval before promotion to development, test, or production targets. Pipeline health is tracked with dashboards, alerting, and Service Level Indicators and Objectives for build and deployment latency, while breakglass procedures require a clear escalation plan, shared custody of secrets, and automated auditing of every emergency use.
Binary Authorization is the pre-deployment gate that allows only trusted images to deploy to GKE, Cloud Run, and GKE Enterprise. The policy maintains an exempt image list and can require attestations, which are signed documents stating that a required process completed, such as a Cloud Build origin or a vulnerability severity check. A missing or invalid attestation stops promotion and preserves supply-chain integrity.
Continuous validation extends that policy to already-running Pods throughout their lifecycle. It does not block running Pods but regularly writes conformance results to Cloud Logging, including Pods admitted through dry-run mode or breakglass bypass. The GKE security posture dashboard adds fleet-level scanning against best practices such as Pod Security Standards, with severity ratings and remediation guidance also logged for audit.
| Control | Enforcement point | Result when violated |
|---|---|---|
| Binary Authorization admission check | Before Pod creation from Artifact Registry images | Deployment is blocked unless exempt or attested |
| Binary Authorization continuous validation | After deployment, throughout Pod lifecycle | Violation is logged to Cloud Logging |
| GKE workload configuration scanning | After deployment, across workloads | Issue is severity-rated with guidance and logged |
Exam tip: Binary Authorization admission control blocks noncompliant images at deploy time, while continuous validation only logs noncompliance for already-running Pods.
Software supply chain integrity connects verifiable builds, centralized storage, continuous scanning, and deployment control into one ordered flow. Cloud Build supports SLSA Level 3 builds and generates authenticated provenance linking image digests to source locations, toolchain, steps, and duration. Artifact Registry centralizes artifacts with remote repositories that cache external sources and virtual repositories that prioritize private packages, while Artifact Analysis scans uploads, monitors for new findings, and supports SBOM and VEX. Binary Authorization then admits only images with required builder, vulnerability, and promotion attestations.
Secure execution means a compromised step cannot read, write, or exfiltrate beyond its need. Each pipeline identity receives only minimum permissions scoped to individual resources, with dedicated accounts per pipeline or environment and Secret Manager for credentials. VPC Service Controls places a perimeter around projects and APIs so code inside cannot call outside resources. Two exfiltration paths drive design: direct exfiltration copies data through pipeline access and is blocked by revoking unneeded access and egress, while indirect exfiltration deploys compromised code that steals data and is contained by the perimeter.
Continue with this study guide: Security of CI/CD tooling
cloudbuild.yaml file defines ordered builder steps that share a workspace, and a Cloud Build trigger binds source, branch filter, config path, substitutions, and service account so only matching pushes build.$SHORT_SHA or $COMMIT_SHA ties each Artifact Registry image to its exact commit, and that tag is written into Kubernetes manifests to link integration output to delivery.skaffold diagnose and skaffold render, then runs skaffold apply with kubectl on each rollout, with Skaffold profiles selecting per-target Kustomize overlays.Standard repositories store private artifacts uploaded by builds, remote repositories store cached copies from an external source such as Docker Hub, Maven Central, or PyPI, and virtual repositories store no artifacts directly and forward each client request to upstream repositories in priority order. Prioritizing the private standard repository above the remote repository reduces dependency confusion attacks where an attacker publishes a higher-version public package with the same name.
Cloud Deploy renders manifests for every target at release creation through Cloud Build running skaffold diagnose to validate and skaffold render to hydrate manifests, with Skaffold profiles selecting per-target Kustomize overlays. Each promotion then applies the already-rendered manifest for the next target in sequence order by running skaffold apply with kubectl as the deployer.
Binary Authorization admission control blocks deployment before Pod creation unless the image is exempt or has required attestations. Continuous validation does not block running Pods but regularly writes conformance results for already-running Pods to Cloud Logging.
cloudbuild.yaml pipeline in Cloud Build that tests code, builds container images, and distributes …Last updated