Top 20 GCP Cloud Build & CI/CD Interview Questions
- What is Cloud Build?
- What is Artifact Registry?
- What is Cloud Deploy?
- How do you create a build config?
- What are build triggers?
- How do you build Docker images?
- What are Cloud Build substitutions?
- How do you manage secrets in builds?
- What are build pools?
- How do you run tests in Cloud Build?
- What are Artifact Registry repositories?
- How do you implement blue-green deployments?
- What are Cloud Deploy pipelines?
- How do you implement GitOps?
- What are approval gates?
- How do you monitor builds?
- What are Cloud Build workers?
- How do you optimize build times?
- What is vulnerability scanning?
- What are CI/CD best practices?
☁ Google Cloud Interview Questions
📊 GCP Data Engineer
BigQuery, Dataflow, Pub/Sub, GCS
⚡ Cloud Functions
Serverless, Triggers, Cloud Run
🗃 BigQuery
Data Warehouse, ML, Analytics
📦 Cloud Storage & Data Lake
GCS, Dataplex, Data Catalog
🚀 Dataproc & Dataflow
Spark, Hadoop, Apache Beam
🔄 Workflows & Composer
Orchestration, Airflow, Scheduling
🔒 IAM & Identity
Roles, Service Accounts, Identity Platform
🤖 Vertex AI
ML Platform, AutoML, Pipelines
🛠 Cloud Build & Deploy
CI/CD, Artifact Registry, GKE
📨 Pub/Sub & Streaming
Messaging, Streaming, Event-Driven
🎯 Data Engineering Scenarios
Real-world Architecture Questions
1. What is Cloud Build?
Cloud Build is a serverless CI/CD platform that executes builds on GCP infrastructure.Cloud Build Features: +-- Serverless build execution +-- Docker image building +-- Any language/tool support +-- Automatic scaling +-- Built-in triggers +-- Integration with GCP services +-- Private worker pools Cloud Build Architecture: +-------------------------------------------------------------+ | Cloud Build | +-------------------------------------------------------------+ | +-----------------------------------------------------+ | | | Triggers | | | | +-- Push to branch | | | | +-- Pull request | | | | +-- Tag push | | | | +-- Manual/API | | | +-----------------------------------------------------+ | | | | | +-----------------------------------------------------+ | | | Build Execution | | | | +---------+ +---------+ +---------+ +---------+ | | | | | Step 1 |>| Step 2 |>| Step 3 |>| Step 4 | | | | | |(Build) | |(Test) | |(Package)| |(Deploy) | | | | | +---------+ +---------+ +---------+ +---------+ | | | +-----------------------------------------------------+ | | | | | +-----------------------------------------------------+ | | | Outputs | | | | +-- Container images | | | | +-- Build artifacts | | | | +-- Logs | | | +-----------------------------------------------------+ | +-------------------------------------------------------------+ # Enable Cloud Build gcloud services enable cloudbuild.googleapis.com # Submit build manually gcloud builds submit --config=cloudbuild.yaml . # List builds gcloud builds list --limit=10 # View build logs gcloud builds log BUILD_ID
2. What is Artifact Registry?
Artifact Registry is a fully managed service for storing and managing build artifacts and dependencies.
Artifact Registry Features:
+-- Docker images
+-- Language packages (npm, Maven, Python, Go)
+-- Helm charts
+-- OS packages (apt, yum)
+-- Regional and multi-regional
+-- IAM integration
+-- Vulnerability scanning
+-- Cleanup policies
# Create repository
gcloud artifacts repositories create my-repo \
--repository-format=docker \
--location=us-central1 \
--description="Docker images"
# Configure Docker authentication
gcloud auth configure-docker us-central1-docker.pkg.dev
# Push image
docker tag my-image us-central1-docker.pkg.dev/my-project/my-repo/my-image:v1
docker push us-central1-docker.pkg.dev/my-project/my-repo/my-image:v1
# List images
gcloud artifacts docker images list us-central1-docker.pkg.dev/my-project/my-repo
# Create Python repository
gcloud artifacts repositories create python-repo \
--repository-format=python \
--location=us-central1
# Configure pip
gcloud artifacts print-settings python \
--project=my-project \
--repository=python-repo \
--location=us-central1
# npm repository
gcloud artifacts repositories create npm-repo \
--repository-format=npm \
--location=us-central1
# Configure npm
gcloud artifacts print-settings npm \
--project=my-project \
--repository=npm-repo \
--location=us-central1
3. What is Cloud Deploy?
Cloud Deploy is a managed continuous delivery service for deploying to GKE and Cloud Run.
Cloud Deploy Architecture:
+-------------------------------------------------------------+
| Cloud Deploy |
+-------------------------------------------------------------+
| +-----------------------------------------------------+ |
| | Delivery Pipeline | |
| | | |
| | +-----+ +---------+ +---------+ | |
| | | Dev |--->| Staging |--->| Prod | | |
| | +-----+ +---------+ +---------+ | |
| | (approval) (approval) | |
| +-----------------------------------------------------+ |
| |
| +-----------------------------------------------------+ |
| | Targets | |
| | +-- GKE Clusters | |
| | +-- Cloud Run Services | |
| | +-- Anthos | |
| +-----------------------------------------------------+ |
+-------------------------------------------------------------+
# delivery-pipeline.yaml
apiVersion: deploy.cloud.google.com/v1
kind: DeliveryPipeline
metadata:
name: my-pipeline
description: Main delivery pipeline
serialPipeline:
stages:
- targetId: dev
profiles: [dev]
- targetId: staging
profiles: [staging]
- targetId: prod
profiles: [prod]
strategy:
canary:
runtimeConfig:
kubernetes:
serviceNetworking:
service: my-service
canaryDeployment:
percentages: [25, 50, 75]
verify: true
# targets.yaml
apiVersion: deploy.cloud.google.com/v1
kind: Target
metadata:
name: dev
description: Dev cluster
gke:
cluster: projects/my-project/locations/us-central1/clusters/dev-cluster
---
apiVersion: deploy.cloud.google.com/v1
kind: Target
metadata:
name: prod
description: Production cluster
gke:
cluster: projects/my-project/locations/us-central1/clusters/prod-cluster
requireApproval: true
# Create pipeline
gcloud deploy apply --file=delivery-pipeline.yaml --region=us-central1
gcloud deploy apply --file=targets.yaml --region=us-central1
# Create release
gcloud deploy releases create release-001 \
--delivery-pipeline=my-pipeline \
--region=us-central1 \
--images=my-app=us-central1-docker.pkg.dev/my-project/repo/app:v1
4. How do you create a build config?
cloudbuild.yaml Structure:
# cloudbuild.yaml
steps:
# Step 1: Build application
- name: 'gcr.io/cloud-builders/npm'
args: ['install']
# Step 2: Run tests
- name: 'gcr.io/cloud-builders/npm'
args: ['test']
# Step 3: Build Docker image
- name: 'gcr.io/cloud-builders/docker'
args:
- 'build'
- '-t'
- 'us-central1-docker.pkg.dev/$PROJECT_ID/my-repo/my-app:$SHORT_SHA'
- '-t'
- 'us-central1-docker.pkg.dev/$PROJECT_ID/my-repo/my-app:latest'
- '.'
# Step 4: Push image
- name: 'gcr.io/cloud-builders/docker'
args:
- 'push'
- 'us-central1-docker.pkg.dev/$PROJECT_ID/my-repo/my-app:$SHORT_SHA'
# Images to push automatically
images:
- 'us-central1-docker.pkg.dev/$PROJECT_ID/my-repo/my-app:$SHORT_SHA'
- 'us-central1-docker.pkg.dev/$PROJECT_ID/my-repo/my-app:latest'
# Build artifacts to store
artifacts:
objects:
location: 'gs://$PROJECT_ID-artifacts/'
paths: ['build/**']
# Build options
options:
machineType: 'E2_HIGHCPU_8'
diskSizeGb: 100
logging: CLOUD_LOGGING_ONLY
# Timeout
timeout: '1200s'
# Service account
serviceAccount: 'projects/my-project/serviceAccounts/build-sa@my-project.iam.gserviceaccount.com'
# Environment variables
env:
- 'NODE_ENV=production'
- 'API_URL=https://api.example.com'
# Step-specific options
steps:
- name: 'gcr.io/cloud-builders/docker'
args: ['build', '-t', 'my-image', '.']
timeout: '600s'
dir: 'app/'
env:
- 'DOCKER_BUILDKIT=1'
5. What are build triggers?
Build Triggers:
# Create push trigger
gcloud builds triggers create github \
--name=push-trigger \
--repo-name=my-repo \
--repo-owner=my-org \
--branch-pattern='^main$' \
--build-config=cloudbuild.yaml
# Create PR trigger
gcloud builds triggers create github \
--name=pr-trigger \
--repo-name=my-repo \
--repo-owner=my-org \
--pull-request-pattern='^main$' \
--build-config=cloudbuild-pr.yaml \
--comment-control=COMMENTS_ENABLED
# Create tag trigger
gcloud builds triggers create github \
--name=release-trigger \
--repo-name=my-repo \
--repo-owner=my-org \
--tag-pattern='^v[0-9]+\.[0-9]+\.[0-9]+$' \
--build-config=cloudbuild-release.yaml
# Trigger configuration via YAML
# trigger.yaml
name: my-trigger
description: Main build trigger
github:
owner: my-org
name: my-repo
push:
branch: ^main$
includedFiles:
- 'src/**'
ignoredFiles:
- 'docs/**'
- '*.md'
filename: cloudbuild.yaml
substitutions:
_DEPLOY_ENV: production
_REGION: us-central1
# Create from file
gcloud builds triggers create --file=trigger.yaml
# Manual trigger
gcloud builds triggers run my-trigger \
--branch=main \
--substitutions=_DEPLOY_ENV=staging
# Webhook trigger
gcloud builds triggers create webhook \
--name=webhook-trigger \
--secret=projects/my-project/secrets/webhook-secret/versions/latest \
--build-config=cloudbuild.yaml