Courseiva

CCNA Deploying and Implementing a Cloud Solution Questions

66 questions · Deploying and Implementing a Cloud Solution · All types, answers revealed

1
MCQmedium

After deploying a Kubernetes Deployment named 'web-app', a developer wants to expose it externally on a static IP address. Which kubectl command should they use?

A.kubectl create service clusterip web-app --tcp=80:8080
B.gcloud compute forwarding-rules create web-app --port=80
C.kubectl expose deployment web-app --type=LoadBalancer --port=80 --target-port=8080
D.kubectl expose deployment web-app --type=NodePort --port=80
AnswerC

This is the correct approach because `kubectl expose deployment` with `--type=LoadBalancer` automatically creates a Kubernetes Service that instructs GKE to provision a cloud load balancer and allocate an external IP address. The `--port=80` specifies the Service port, while `--target-port=8080` directs traffic to the container's actual listening port on the Pod, matching the Deployment's container specification. If a reserved static IP is needed, you would reserve it in advance and add the `--load-balancer-ip` flag or annotate the Service; GKE then assigns that address to the load balancer.

Why this answer

kubectl expose creates a service. To get an external load balancer with a static IP, the service type must be LoadBalancer. The --type flag specifies the service type.

2
MCQmedium

You have a managed instance group (MIG) with instances that need to run a startup script to configure monitoring agents. You created the instance template without a startup script. Which action should you take to add the startup script?

A.Use gcloud compute instances add-metadata to add the startup script to each running instance.
B.Delete the MIG and recreate it with a new template; you cannot change the template of an existing MIG.
C.Edit the existing instance template and add the startup script under 'metadata'.
D.Create a new instance template with the startup script, then update the MIG to use the new template via a rolling update.
AnswerD

The correct approach is to create a new instance template that includes the desired startup script in its metadata, then update the MIG to reference this new template using a rolling update. Since instance templates are immutable, creating a new template is mandatory. A rolling update (e.g., gcloud compute instance-groups managed rolling-action start-update) recreates the managed instances incrementally with the new template, ensuring the startup script executes during their boot. This method preserves availability and aligns with the MIG's declarative management model.

Why this answer

Instance templates are immutable; you cannot modify them. You must create a new instance template with the startup script and update the MIG to use it via rolling update or by setting the template.

3
MCQhard

An engineer needs to migrate a large on-premises database to Cloud SQL for PostgreSQL. The database is 500 GB and can tolerate a few hours of downtime. The migration must minimize manual intervention. Which approach should the engineer use?

A.Use Database Migration Service (DMS)
B.Use pg_dump to export and pg_restore to import
C.Use gcloud sql import to import a dump file
D.Set up a Compute Engine instance to run pg_dump and then gcloud sql import
AnswerA

Database Migration Service (DMS) is a fully managed service that automates the entire migration process, including a one-time full load followed by continuous change data capture (CDC) from the source database. This approach keeps the on-premises database online and synchronized during the migration, so you can cut over with minimal downtime. For a large database, DMS handles the heavy lifting of snapshotting and applying changes without needing to manually create or transfer dump files.

Why this answer

Database Migration Service supports homogeneous migrations (including PostgreSQL to Cloud SQL) and automates the process. It supports continuous replication and minimal downtime. The others are not ideal: pg_dump requires manual steps and downtime; gcloud sql import is for file import; Compute Engine with pg_dump involves manual steps.

4
MCQhard

You are managing a Cloud Functions deployment that processes messages from a Pub/Sub topic. You need to ensure the function can read messages from the topic and acknowledge them. Which IAM role should you assign to the function's service account?

A.roles/pubsub.publisher
B.roles/pubsub.subscriber
C.roles/pubsub.viewer
D.roles/iam.serviceAccountUser
AnswerB

The Pub/Sub Subscriber role (roles/pubsub.subscriber) is the correct, least-privileged role for a Cloud Functions trigger. It includes the permissions needed to pull messages (pubsub.subscriptions.consume) and acknowledge them after processing (pubsub.subscriptions.acknowledge), which is exactly what the function's runtime service account must do to read and complete each message from its subscription.

Why this answer

The Pub/Sub Subscriber role (roles/pubsub.subscriber) grants permission to pull messages and acknowledge them. The function's service account needs this role on the topic or subscription.

5
MCQmedium

An administrator needs to create a Cloud SQL for PostgreSQL instance with 16 vCPUs and 60 GB of memory. Which tier should they specify?

A.db-custom-16-60
B.db-custom-16-61440
C.db-n1-standard-16
D.db-custom-16-60000
AnswerB

This is the correct custom tier string because it conforms to the required db-custom-<vCPUs>-<memory_in_MB> format for Cloud SQL custom machine types. It specifies 16 vCPUs and 61,440 MB of memory, which is exactly 60 GB when applying the binary conversion factor of 1024 MB per GB. This string accurately represents the administrator's desired 16 vCPU / 60 GB configuration in the unit that Cloud SQL actually uses.

Why this answer

Cloud SQL tiers follow the pattern db-custom-#vcpus-#memoryMB. 16 vCPUs and 60 GB (61440 MB) uses db-custom-16-61440.

6
MCQmedium

A developer wants to deploy a containerized application on Google Cloud that automatically scales to zero when not in use and charges only for request processing time. The application is stateless and can be triggered by HTTP requests. Which compute option meets these requirements?

A.Compute Engine with managed instance groups
B.Cloud Functions
C.Cloud Run
D.Google Kubernetes Engine (GKE) with cluster autoscaling
AnswerC

Cloud Run is a fully managed serverless platform that runs stateless HTTP-triggered containers directly from a container image. It automatically scales down to zero when there are no incoming requests, so you incur no charges while idle, and bills only for request duration (CPU, memory, and concurrency metered during request handling). You can deploy any container that listens on HTTP, making it the ideal low-overhead choice for a containerized web application. Unlike GKE or Compute Engine, there is no infrastructure to manage or minimum charge for a running VM.

Why this answer

Cloud Run is a fully managed serverless platform that scales to zero and charges per request. It is ideal for stateless HTTP-triggered containers. Compute Engine and GKE do not scale to zero (idle resources incur cost).

Cloud Functions is also serverless but is for event-driven code, not containerized apps.

7
MCQmedium

A company wants to migrate an on-premises MySQL database to Cloud SQL. They need to import an existing SQL dump file stored in a Cloud Storage bucket. Which command should they use?

A.gcloud compute ssh my-instance --command='mysql < dump.sql'
B.gcloud sql import sql my-instance gs://my-bucket/dump.sql --database=mydb
C.gcloud sql databases create mydb --instance=my-instance --import=gs://my-bucket/dump.sql
D.gsutil cp gs://my-bucket/dump.sql | mysql -h my-instance -u root -p
AnswerB

This is the correct command to import a SQL dump file into a Cloud SQL MySQL instance. The `gcloud sql import sql` command takes the instance name, the Cloud Storage URI of the dump, and the `--database` flag to specify the target database. The Cloud SQL instance's service account must have `storage.objectViewer` permission on the bucket, and the database must already exist. This is the supported, asynchronous import method for managed Cloud SQL.

Why this answer

gcloud sql import sql is the correct command to import a SQL dump file into a Cloud SQL instance. The command specifies the instance, the bucket path, and the database name.

8
MCQhard

A team is using Terraform to manage Google Cloud resources. They want to store the Terraform state file in a Cloud Storage bucket to enable collaboration. Which Terraform backend configuration should be used?

A.provider "google" { backend "gcs" { bucket = "my-tf-state" } }
B.terraform { backend "cloud-storage" { bucket = "my-tf-state" path = "prod" } }
C.terraform { backend "gcs" { bucket = "my-tf-state" folder = "prod" } }
D.terraform { backend "gcs" { bucket = "my-tf-state" prefix = "prod" } }
AnswerD

This is the correct way to configure remote state storage for Google Cloud using Terraform. The `terraform` block wraps the backend declaration, the type is `gcs` for Google Cloud Storage, and the `bucket` and `prefix` arguments accurately define the bucket name and the object key within that bucket. Using a distinct prefix like `"prod"` allows multiple environments or components to share the same bucket while keeping their state files isolated and easily retrievable.

Why this answer

The 'gcs' backend in Terraform stores state in a Cloud Storage bucket. The 'bucket' attribute specifies the bucket name, and 'prefix' is optional for folder structure.

9
MCQeasy

Which gcloud command creates a regional GKE cluster named 'my-cluster' with 3 nodes per zone in the 'us-central1' region?

A.gcloud container clusters create my-cluster --zone us-central1 --num-nodes 3
B.gcloud container clusters create my-cluster --zone us-central1-a --num-nodes 3
C.gcloud container clusters create my-cluster --region us-central1 --nodes 3
D.gcloud container clusters create my-cluster --region us-central1 --num-nodes 3
AnswerD

This is the correct command because it uses --region us-central1 to designate a regional cluster, which GKE deploys across multiple zones within that region for redundancy and high availability. The --num-nodes 3 flag sets the number of nodes per zone in the default node pool, ensuring each zone gets three nodes. Together, these flags meet the requirement for a regional GKE cluster named my-cluster.

Why this answer

To create a regional cluster, use --region (not --zone). The --num-nodes flag sets nodes per zone.

10
MCQeasy

A company wants to create a Cloud Storage bucket to store archival data that is accessed infrequently (less than once a year). The data must be stored at the lowest possible cost. Which storage class should they choose?

A.Archive
B.Coldline
C.Nearline
D.Standard
AnswerA

Archive is the correct choice because it is the lowest-cost Cloud Storage class for data that is accessed less than once a year, offering the cheapest per-gigabyte monthly price for long-term retention. It does incur retrieval fees and a 365-day minimum storage duration, but for true archival data with infrequent access these trade-offs are acceptable. This class also has no availability SLA, which is fine for this access pattern but means it should only be used for durable, rarely accessed data.

Why this answer

Archive storage class is the lowest-cost option for long-term archival data accessed less than once a year. Nearline and Coldline have higher retrieval costs but are for data accessed less frequently than standard, not as low as Archive. Standard is for frequently accessed data.

11
MCQeasy

Which kubectl command lists all pods in the current namespace?

A.kubectl list pods
B.kubectl describe pods
C.kubectl get pods
D.kubectl get all
AnswerC

'kubectl get pods' is the canonical command to list pods in the current namespace. It queries the Kubernetes API and returns a table with columns such as NAME, READY, STATUS, RESTARTS, and AGE, one row per pod. This is the expected answer because the question asks for a command that lists pods, and 'get' is the standard verb for retrieving resource lists.

Why this answer

The command 'kubectl get pods' lists all pods. 'kubectl get all' includes services, deployments, etc. 'kubectl describe pods' shows detailed info. 'kubectl list pods' is invalid.

12
MCQeasy

An engineer needs to SSH into a Compute Engine instance using OS Login. What must be enabled first?

A.Create an SSH key and upload to the instance
B.Grant the compute.osLogin role to the user
C.Add SSH keys to the project metadata
D.Enable OS Login in the project metadata
AnswerD

Enabling OS Login by setting the project metadata key enable-oslogin to TRUE is the foundational step. This tells Compute Engine to use IAM-based authentication for SSH, allowing the engineer to log in with Google credentials rather than managing SSH keys. Once enabled at the project level, instances inherit the setting, and a user with the compute.osLogin role can SSH without manual key distribution. This is the required first action to meet the engineer's need.

Why this answer

OS Login must be enabled at the project or instance level using 'gcloud compute project-info add-metadata --enable-oslogin' or similar. Direct SSH key metadata is not needed if OS Login is used.

13
MCQhard

An engineer is using Terraform to manage GCP resources. They want to store the Terraform state file remotely so that the team can collaborate. Which backend configuration should they use?

A.backend "cloud" { bucket = "my-terraform-state" }
B.backend "local" { path = "terraform.tfstate" }
C.backend "consul" { address = "consul.example.com" }
D.backend "gcs" { bucket = "my-terraform-state" }
AnswerD

Configuring the gcs backend with a bucket name is the correct way to store Terraform state for GCP resources. The gcs backend uses a Cloud Storage bucket, which natively supports state file versioning, server-side encryption (including customer-managed keys via Cloud KMS), and access control through GCP IAM, providing both security and consistency for team use. It also enables state locking via bucket objects to prevent concurrent modifications. This is the recommended solution for centralized, durable remote state in GCP.

Why this answer

Terraform supports storing state in GCS by using the 'gcs' backend. The bucket must be created before configuration. The 'local' backend stores state locally, which does not enable collaboration. 'cloud' is not a valid backend type. 'consul' is not GCP-native.

14
MCQmedium

A company wants to run a stateful application on Compute Engine with persistent storage that can be attached to another instance in case of failure. Which storage option should they use?

A.Filestore
B.Cloud Storage bucket
C.Persistent Disk
D.Local SSD
AnswerC

Persistent Disk is durable, network-attached block storage that you can attach to a Compute Engine instance like a physical disk. It survives instance stops and can be detached from one instance and reattached to another, enabling stateful failover. Persistent Disk also supports snapshots, resizing, and zonal or regional replication, making it the appropriate choice for a stateful application. For these reasons, Persistent Disk is the correct answer.

Why this answer

Persistent Disk (PD) is a network-attached block storage that can be detached and reattached to another VM in the same zone. Option C is correct. Option A (Filestore) is a file storage service, not block storage; Option B (Cloud Storage bucket) is object storage; Option D (Local SSD) is ephemeral and tied to the instance.

15
MCQmedium

You deployed a Cloud Run service with gcloud run deploy --image gcr.io/my-project/my-image --platform managed --region us-central1 --allow-unauthenticated. Users report intermittent 503 errors. What is the most likely cause?

A.The service is hitting the maximum number of concurrent requests per container instance (default 80) and needs more instances.
B.The region us-central1 does not support Cloud Run.
C.The container image is not compatible with the managed platform.
D.The --allow-unauthenticated flag causes IAM permission errors.
AnswerA

A 503 from Cloud Run specifically signals that a request arrived but no container instance was available to accept it within the timeout window. Each instance can process only a fixed number of concurrent requests—the default concurrency is 80—so when all existing instances are saturated and the autoscaler cannot add new instances quickly enough (or the 'max instances' setting has been reached), the server returns Service Unavailable. The fix is to raise the max instances limit, lower the concurrency setting, or enable additional CPU to reduce per-instance bottleneck.

Why this answer

Cloud Run services have a default maximum number of concurrent requests per container instance (default 80). If traffic exceeds that, new instances are created, but if there is a sudden spike or the container takes too long to start, requests may be dropped with 503. Increasing max instances or concurrency settings can help.

16
Multi-Selecteasy

A developer wants to deploy a Cloud Function that is triggered by messages in a Pub/Sub topic. Which TWO flags are required in the gcloud functions deploy command?

Select 2 answers
A.--runtime
B.--trigger-topic
C.--timeout
D.--memory
E.--entry-point
AnswersA, B

The `--runtime` flag is mandatory because it tells the Cloud Functions deployment service which language runtime to use, such as `python312` or `nodejs20`. This value must match the code you are uploading, including the expected base image and dependencies, so the platform can build the function in the correct environment. Without specifying it, the gcloud command will fail, as there is no sensible default language choice.

Why this answer

For a Pub/Sub-triggered Cloud Function, you must specify --trigger-topic and --runtime. The --entry-point is optional if the function name matches. --memory and --timeout are optional.

17
MCQmedium

A developer wants to create a Compute Engine instance with the container-optimized OS image in the default network. Which command should they use?

A.gcloud compute instances create my-instance --image-family=ubuntu-2004-lts --image-project=ubuntu-os-cloud
B.gcloud compute instances create my-instance --image-family=cos-stable --image-project=cos-cloud
C.gcloud compute instances create my-instance --image-family=cos-stable
D.gcloud compute instances create my-instance --image=cos-stable --image-project=cos-cloud
AnswerB

This is the correct command because it explicitly selects the 'cos-stable' image family from the 'cos-cloud' project, which yields the latest stable release of Container-Optimized OS. COS is a Google-supported OS with Docker, containerd, and Kubernetes tools preinstalled, optimized for running containerized workloads. Including both --image-family and --image-project ensures that gcloud resolves the family from the proper project, avoiding ambiguity with the default compute project.

Why this answer

The correct command uses '--image-family=cos-stable' and '--image-project=cos-cloud' to specify the Container-Optimized OS image. Option B uses 'gcloud compute instances create' with the correct flags.

18
MCQmedium

An organization wants to deploy a containerized web application on Google Cloud with minimum operational overhead. The application should scale to zero when not in use and only incur costs when serving requests. Which service should they choose?

A.App Engine Flexible Environment
B.Google Kubernetes Engine (GKE)
C.Compute Engine with container-optimized OS
D.Cloud Run
AnswerD

Cloud Run is a fully managed serverless platform that executes containers in a stateless, request-driven model: when there are no incoming requests, it can scale the service down to zero instances, so you are not charged for idle resources. It automatically scales up to handle traffic spikes, and billing is based on request duration and CPU/memory usage during active processing, measured in 100ms increments. This makes it the most operationally efficient choice for a containerized web application that expects variable traffic.

Why this answer

Cloud Run is a fully managed serverless platform that scales to zero, charges only for request processing time, and abstracts infrastructure management. GKE requires cluster management and nodes always running. App Engine Flexible requires at least one instance always running.

Compute Engine requires full VM management.

19
Multi-Selectmedium

You need to deploy an application that requires a regional MySQL database with automated backups, high availability, and failover. You also need to store static assets that are publicly accessible. Which TWO Google Cloud services should you use?

Select 2 answers
A.Cloud SQL (MySQL)
B.Cloud Storage
C.Bigtable
D.Cloud Filestore
E.Cloud Spanner
AnswersA, B

Cloud SQL for MySQL is a fully managed relational database service that provides the exact MySQL engine required by the application. It supports regional high availability through synchronous replication across two zones, automated backups, and point-in-time recovery, meeting both performance and durability needs without operational overhead. Its compatibility with standard MySQL drivers and protocols makes it the ideal choice for a regional MySQL workload.

Why this answer

Cloud SQL with MySQL provides managed MySQL with high availability (regional) and automated backups. Cloud Storage can host static assets publicly.

20
MCQeasy

You want to deploy a Cloud Function triggered by HTTP requests. The function is written in Node.js and the entry point function is named 'helloHttp'. Which command should you use?

A.gcloud functions deploy my-function --runtime nodejs16 --trigger-http --entry-point=helloHttp --region=us-central1
B.gcloud functions deploy --source . --runtime nodejs16 --trigger-http --entry-point=helloHttp
C.gcloud run deploy my-function --source . --runtime nodejs16 --entry-point=helloHttp
D.gcloud functions deploy my-function --runtime nodejs16 --trigger-topic my-topic --entry-point=helloHttp
AnswerA

This command is correct because it explicitly provides the required function name (`my-function`), specifies the Node.js 16 runtime, sets `--trigger-http` to create an HTTP-triggered Cloud Function, names the entry point (`helloHttp`) that matches the exported function in your source code, and pins the region (`us-central1`) to avoid ambiguity. In Cloud Functions, `--trigger-http` creates a public HTTPS endpoint and deploys the function to the specified location, making this the complete and valid invocation.

Why this answer

The correct command specifies the runtime (nodejs16), trigger (--trigger-http), entry point (--entry-point=helloHttp), and region. --trigger-topic is for Pub/Sub, not HTTP.

21
MCQhard

A DevOps engineer is configuring a managed instance group (MIG) for a stateless web application. They want to ensure that when new instances are created via rolling update or autoscaling, a startup script runs to install security patches and deploy the latest application code from a Cloud Storage bucket. What is the BEST way to achieve this?

A.Create a custom image with pre-installed patches and code, and use that image in the template
B.After the MIG is created, use gcloud compute ssh to run the script on each instance
C.Store the script in Cloud Storage and use gcloud compute instances add-metadata on each instance
D.Add the script to the instance template using the metadata key 'startup-script'
AnswerD

Adding the script to the instance template using the metadata key 'startup-script' is the recommended, automated approach because Compute Engine stores the metadata in the instance template and executes the script on every VM boot. The MIG automatically applies this metadata to all instances it creates, including during autoscaling, rolling updates, and instance recreation after a failure. This guarantees the configuration is consistently applied without manual intervention, and the script can be updated by editing the template and rolling out a new version of the MIG.

Why this answer

Using the instance template's metadata key 'startup-script' is the simplest and most reliable method to run custom scripts on instance startup. A custom image requires more maintenance. SSH from Cloud Shell is not automated.

A startup script as part of the instance template is the standard approach.

22
MCQmedium

A company wants to deploy a microservice on GKE. The deployment requires 3 replicas, and the service must be accessible via a fixed public IP address. Which Kubernetes resource should be used to expose the deployment?

A.Service of type LoadBalancer
B.Ingress resource
C.Service of type ClusterIP
D.Service of type NodePort
AnswerA

A Service of type LoadBalancer in GKE creates an external passthrough Network Load Balancer in Google Cloud, provisioning an external forwarding rule with a stable public IP address from a regional pool. This IP remains fixed for the lifetime of the Service unless the Service is deleted or a reserved static IP is explicitly configured, making it the correct choice for a microservice that needs a durable public endpoint without additional configuration.

Why this answer

A LoadBalancer service provisions a Google Cloud TCP/UDP Load Balancer with a public IP. NodePort exposes on node ports but not a fixed IP. ClusterIP is internal only.

Ingress is a more advanced option but not the simplest for a fixed IP.

23
MCQmedium

A company wants to store archival data that is accessed less than once a year. The data must be preserved for 10 years. Which Cloud Storage storage class is most cost-effective?

A.Archive
B.Standard
C.Nearline
D.Coldline
AnswerA

Archive is the cheapest, designed for data accessed less than once a year.

Why this answer

Archive class is the lowest-cost storage for data accessed less than once a year, with a 365-day minimum storage duration. Coldline is slightly more expensive but for less than once a year, Archive is better.

24
Multi-Selecteasy

A developer is deploying a new application on GKE and needs to configure a HorizontalPodAutoscaler (HPA). Which two resources are required for HPA to work correctly?

Select 2 answers
A.CPU utilization metrics
B.A Service
C.A ConfigMap
D.A Deployment
E.A NodePort service
AnswersA, D

CPU utilization metrics drive the Horizontal Pod Autoscaler's scaling decisions. By default, HPA reads the average CPU utilization across all pods in a target Deployment, comparing it against the target percentage you set relative to each pod's CPU request. This is the most common and default metric type, requiring pods to have explicit `resources.requests.cpu` values. Custom and external metrics can be used, but CPU utilization is the built-in, standard input for autoscaling.

Why this answer

HPA requires a deployment (or other scalable resource) and a target metric, usually CPU utilization. The HPA will scale the deployment based on the metric. A ConfigMap and a service are not strictly required for HPA.

25
Multi-Selectmedium

A team is deploying a web application on Cloud Run. The application needs to be available globally with low latency, and the team wants to use a custom domain with an SSL certificate. Which TWO actions are required to achieve this?

Select 2 answers
A.Set the --ingress=all flag on the Cloud Run service
B.Use Cloud CDN to cache content
C.Configure a custom domain mapping on the Cloud Run service
D.Deploy the Cloud Run service in multiple regions and use a multi-regional load balancer
E.Deploy the service as a Cloud Run for Anthos on GKE
AnswersC, D

Custom domain mapping on Cloud Run registers the domain and provisions a Google-managed TLS certificate so the domain points to the service's default URL. This is a mandatory step to expose the application at the customer's chosen domain. While it handles the domain mapping, it does not by itself provide multi-region low latency; that requires a global load balancer with multiple regional backends.

Why this answer

Cloud Run services are regional; to serve globally, you need a global load balancer (e.g., using an external HTTPS load balancer with serverless NEG). Mapping a custom domain to the service is also required.

26
MCQmedium

A company wants to deploy a containerized application on Google Cloud that automatically scales to zero when not in use, and they want to minimize operational overhead. They also need to avoid managing any underlying infrastructure such as Kubernetes clusters or VMs. Which service should they use?

A.Google Kubernetes Engine (GKE)
B.App Engine Standard Environment
C.Cloud Run
D.Compute Engine with managed instance groups
AnswerC

Cloud Run is a fully managed serverless container platform that automatically scales in response to incoming requests, including scaling to zero when idle, so you only pay for the exact compute time consumed. It doesn't require any cluster or infrastructure management, and it can be used with Knative Serving APIs, making it the most direct fit for a stateless containerized application that needs to scale to zero.

Why this answer

Cloud Run is a fully managed serverless platform that can scale to zero when there is no traffic, and it abstracts away infrastructure management. GKE requires managing a cluster, Compute Engine involves managing VMs, and App Engine is also serverless but Cloud Run provides more flexibility with containers and also scales to zero.

27
MCQeasy

Which gcloud command is used to deploy a Cloud Function triggered by HTTP requests?

A.gcloud functions call my-function --data '{"key":"value"}'
B.gcloud run deploy my-function --source . --platform managed
C.gcloud functions deploy my-function --runtime python39 --trigger-http
D.gcloud functions deploy my-function --runtime python39 --trigger-topic my-topic
AnswerC

This command correctly deploys an HTTP-triggered Cloud Function: `gcloud functions deploy` creates or updates a function resource, `--runtime python39` selects the Python 3.9 execution environment, and `--trigger-http` configures an HTTPS endpoint that invokes the function on web requests. No other trigger type is needed. The command will return a URL for the deployed function.

Why this answer

The command 'gcloud functions deploy' with --trigger-http creates an HTTP-triggered function. --runtime specifies the language runtime. --trigger-topic is for Pub/Sub triggers.

28
MCQeasy

A developer needs to create a Compute Engine VM with 4 vCPUs, 15 GB of memory, and a Debian 10 boot disk. Which gcloud compute instances create command is correct?

A.gcloud compute instances create my-vm --machine-type=n1-highmem-4 --image-family=debian-10 --image-project=debian-cloud
B.gcloud compute instances create my-vm --machine-type=n1-standard-4 --image-family=debian-10 --image-project=debian-cloud
C.gcloud compute instances create my-vm --machine-type=n1-standard-4 --image-family=ubuntu-1804 --image-project=ubuntu-os-cloud
D.gcloud compute instances create my-vm --machine-type=n1-standard-4
AnswerB

This is the correct command because n1-standard-4 is the general-purpose machine type that provides exactly 4 vCPUs and 15 GB of memory, satisfying the stated requirement. It also explicitly sets --image-family=debian-10 and --image-project=debian-cloud, which tells gcloud to use the latest active Debian 10 image from the official debian-cloud project. The command is complete and creates a reproducible Debian 10 VM with the desired vCPU count.

Why this answer

The correct command specifies machine-type n1-standard-4 (4 vCPU, 15 GB RAM), image-family debian-10, and image-project debian-cloud. The other options either use wrong machine type, wrong image project, or miss required flags.

29
MCQeasy

Which kubectl command is used to view the logs of a specific pod named 'my-pod'?

A.kubectl logs my-pod
B.kubectl exec my-pod -- logs
C.kubectl get pod my-pod
D.kubectl describe pod my-pod
AnswerA

The `kubectl logs my-pod` command retrieves the logs of the primary container running inside the specified pod by reading the container's stdout/stderr streams. This is the direct, native Kubernetes approach for accessing application log output, and if the pod has multiple containers, you must append `-c <container>` to select a specific one. It does not require shell access or any extra tooling, making it the correct command for viewing logs.

Why this answer

The 'kubectl logs' command streams logs from a pod. 'kubectl describe' shows metadata, 'kubectl get' shows status, and 'kubectl exec' runs commands inside the pod.

30
Multi-Selectmedium

A company wants to set up a Cloud SQL for MySQL instance with automated backups and a read replica for disaster recovery. Which THREE features or configurations should be enabled?

Select 3 answers
A.Enable automated backups
B.Enable binary logging
C.Enable deletion protection on the primary instance
D.Configure the read replica in a different region
E.Assign a public IP address to the read replica
AnswersA, B, D

Automated backups in Cloud SQL are mandatory for point-in-time recovery (PITR) and for creating read replicas. Without them, you cannot perform a restore to a specific timestamp, and you lose the baseline backup needed for replica creation. They also provide a daily recovery point that protects against data loss or corruption.

Why this answer

Automated backups are enabled by default but must be configured. A read replica requires the binary log to be enabled on the primary. The backup location can be set to multi-regional for DR.

Cross-region replication requires a replica in another region. Point-in-time recovery uses binary logs.

31
MCQhard

A team is using Terraform to manage GCP infrastructure. They want to store the state file in a Cloud Storage bucket with versioning enabled. Which backend configuration is correct?

A.provider "google" { backend "gcs" { bucket = "my-bucket" } }
B.terraform { backend "gcs" { bucket = "my-bucket" prefix = "terraform/state" } }
C.terraform { backend "gcs" { bucket = "my-bucket" versioning = true } }
D.terraform { backend "cloud-storage" { bucket = "my-bucket" } }
AnswerB

This is the correct configuration because it uses the required `terraform` block with a `backend "gcs"` block, and includes both the `bucket` name (where the state file is stored) and a `prefix` (the object path within the bucket). The backend type is exactly `"gcs"`, and this syntax registers Google Cloud Storage as the remote state backend, enabling shared state and locking across the team.

Why this answer

To use Cloud Storage as a backend, you must specify 'bucket' and optionally 'prefix' for the state file path. The provider block is for the Google provider, not state storage.

32
MCQmedium

An organization wants to deploy a containerized web application on GKE. They need the application to be accessible from the internet via a stable IP address. Which service type should they use when exposing the deployment?

A.ClusterIP
B.LoadBalancer
C.NodePort
D.ExternalName
AnswerB

A LoadBalancer Service is the appropriate choice for a containerized web application that needs a stable external IP. When you create this Service on Google Kubernetes Engine, the cloud-controller-manager automatically provisions a Google Cloud (TCP/UDP) load balancer and assigns a regional static external IP address. This gives clients a stable, publicly reachable endpoint, which precisely matches the requirement for an internet-facing web application.

Why this answer

A LoadBalancer service type provisions a Google Cloud TCP/UDP Load Balancer and assigns a stable external IP address. NodePort exposes on a high port but requires manual setup; ClusterIP is internal only.

33
MCQeasy

A developer needs to create a zonal GKE cluster with 3 nodes of type e2-standard-4 in zone us-central1-a. Which command should they use?

A.gcloud compute instances create my-cluster --zone=us-central1-a --machine-type=e2-standard-4 --num-nodes=3
B.gcloud container clusters create my-cluster --zone=us-central1-a --num-nodes=3 --machine-type=e2-standard-4
C.gcloud container clusters create my-cluster --zone=us-central1-a --num-nodes=1 --machine-type=e2-standard-4
D.gcloud container clusters create my-cluster --region=us-central1 --num-nodes=3 --machine-type=e2-standard-4
AnswerB

This correct command creates a zonal GKE cluster because --zone targets a single zone, us-central1-a, and the cluster's control plane and nodes are both provisioned there. The --num-nodes=3 flag defines the initial size of the default node pool, and --machine-type=e2-standard-4 sets each node's VM shape. This exactly meets the requirement for a 3-node zonal cluster.

Why this answer

The correct command creates a zonal cluster (single zone) with specified node count and machine type. The --region flag creates a regional cluster, which is not required.

34
Multi-Selectmedium

A company wants to migrate an on-premises MySQL database to Cloud SQL with minimal downtime. The database is 500 GB. Which TWO steps should be taken? (Choose 2 correct answers.)

Select 2 answers
A.Create a Cloud SQL instance to serve as the target for the migration.
B.Export the database using gcloud sql export sql, then import to Cloud SQL.
C.Create a Cloud SQL instance and configure it as an external replica of the on-premises database.
D.Use mysqldump to backup the database and restore into Cloud SQL.
E.Use Database Migration Service to create a continuous migration job.
AnswersA, E

The Database Migration Service requires a pre-provisioned Cloud SQL instance as the destination, so creating one first defines the target tier, storage, and network configuration before any migration job is started. Without an existing instance, DMS has nowhere to replicate the initial snapshot or stream incoming changes. This is the necessary first step in a low-downtime migration, even though the actual data movement happens later via a DMS job.

Why this answer

To minimize downtime, you can perform a Database Migration Service (DMS) continuous migration or export/import with a consistent snapshot. DMS supports MySQL and provides continuous sync. Alternatively, you can export the database using mysqldump, then import, but this requires downtime.

However, for minimal downtime, DMS is best. Another approach is to create a read replica then promote, but Cloud SQL does not support external read replicas directly. The correct two are: use DMS for continuous migration, and optionally create a clone for testing, but the question asks for migration steps.

The best two from the options: use DMS migration job and create a Cloud SQL instance.

35
Multi-Selecthard

A DevOps engineer is responsible for deploying a new microservice to GKE. They need to expose the service externally on a static IP address and scale based on HTTP request load. Which THREE resources must be created? (Choose 3 correct answers.)

Select 3 answers
A.Ingress
B.Deployment
C.Service (type LoadBalancer)
D.ConfigMap
E.HorizontalPodAutoscaler
AnswersB, C, E

A Deployment is the core workload resource that declaratively manages a set of identical pods through a ReplicaSet. It defines the desired state—container image, replicas, and labels—and performs rolling updates and rollbacks, ensuring pods converge to that state. For a stateless microservice, a Deployment is mandatory to run the application reliably; scaling (manually or via HPA) and service selection all operate on the Deployment's pod labels. Without it, you would have no managed pod lifecycle, no self-healing, and no update strategy.

Why this answer

To expose a microservice externally with a static IP and load-based scaling, you typically create a Deployment, a Service of type LoadBalancer (which provisions a TCP load balancer with a static IP), and a HorizontalPodAutoscaler to scale based on CPU (or custom metrics). Ingress is not required if using LoadBalancer, but it's another option. ConfigMap is not needed for this.

36
Multi-Selecthard

A team is deploying a containerized microservice on GKE. They want to ensure the service is externally accessible via a stable IP address and can automatically scale the number of pods based on CPU utilization. Which TWO actions should they perform?

Select 2 answers
A.Expose the deployment using kubectl expose deployment my-service --type=LoadBalancer
B.Set the service type as ClusterIP
C.Create a Cluster Autoscaler on the GKE cluster
D.Create a HorizontalPodAutoscaler targeting the deployment with kubectl autoscale deployment my-service --cpu-percent=80 --min=1 --max=10
E.Expose the deployment using kubectl expose deployment my-service --type=NodePort
AnswersA, D

Running `kubectl expose deployment my-service --type=LoadBalancer` creates a Service of type LoadBalancer, which on GKE signals the cloud controller manager to provision a Google Cloud TCP/UDP load balancer. This load balancer receives a stable external IP address that persists for the lifetime of the Service, independent of node lifecycle. It is the standard way to expose a single deployment to the internet, as it also automatically forwards traffic to the backing pods.

Why this answer

To expose the service externally with a stable IP, use a LoadBalancer service type. To autoscale pods based on CPU, create a HorizontalPodAutoscaler. NodePort only exposes on node IPs, not stable external.

ClusterIP is internal. Cluster autoscaler scales nodes, not pods.

37
MCQmedium

A Cloud Function needs to be triggered whenever a message is published to a Pub/Sub topic. Which 'gcloud functions deploy' command flag is required to set the trigger?

A.--trigger-topic
B.--trigger-http
C.--trigger-event
D.--trigger-bucket
AnswerA

This flag directly associates the Cloud Function with a Pub/Sub topic. When a message is published to that topic, Pub/Sub delivers it as an event to the function, which is how you configure a message-triggered function. Unlike other triggers, this is the standard and only appropriate flag for Pub/Sub message events in the gcloud beta functions deploy command. It ensures the function is invoked asynchronously with the message payload as the event data.

Why this answer

The --trigger-topic flag configures a Cloud Function to be triggered by Pub/Sub messages.

38
MCQhard

An organization has strict security policies requiring that all Compute Engine instances use OS Login for SSH access instead of metadata-based SSH keys. Which two actions must be taken to enforce this for all new instances? (Choose two.)

A.Remove all SSH keys from project metadata
B.Use 'gcloud compute ssh' with the --tunnel-through-iap flag
C.Set metadata 'enable-oslogin=FALSE' at the instance level
D.Set metadata 'block-project-ssh-keys=TRUE' at the instance level
E.Set metadata 'enable-oslogin=TRUE' at the project level
AnswerA, E

Ensures no metadata-based keys exist; OS Login then becomes the only method.

Why this answer

To enforce OS Login, you enable it at the project level project-wide (enabled by a specific metadata key) and ensure instances have no metadata-based SSH keys. The other options are incorrect.

39
Multi-Selecthard

You are deploying a high-traffic web application on GKE. You need to automatically scale the number of pods based on CPU utilization. Which THREE steps are required to set up Horizontal Pod Autoscaling (HPA)?

Select 3 answers
A.Install the metrics-server in the cluster.
B.Enable Stackdriver Monitoring for the cluster.
C.Create a HorizontalPodAutoscaler resource (e.g., via kubectl autoscale).
D.Create a Deployment with resource requests for CPU.
E.Expose the Deployment as a Service of type LoadBalancer.
AnswersA, C, D

The metrics-server aggregates CPU and memory usage from kubelets via the Summary API and exposes them through the metrics.k8s.io API. The HorizontalPodAutoscaler (HPA) controller repeatedly queries that API to obtain current resource utilization; if no metrics-server is installed, the metrics API is unavailable and the HPA reports 'unable to retrieve metrics' and does not scale. It is the lightweight, cluster-local component that provides the raw numbers the HPA needs, whereas GCP's monitoring service is not directly consulted by the HPA.

Why this answer

To use HPA, you need a deployment (or other scalable resource), you need to apply the HPA resource (e.g., via kubectl autoscale), and you must have metrics-server installed to provide metrics. Creating a service is optional.

40
MCQmedium

A developer is using Cloud Functions with HTTP trigger. The function needs to process a request payload and return a response. What is the correct way to send a JSON response from the function?

A.response.end(JSON.stringify({ 'status': 'ok' }))
B.return { 'status': 'ok' }
C.context.done(null, { 'status': 'ok' })
D.res.send({ 'status': 'ok' })
AnswerD

res.send({ 'status': 'ok' }) is the correct, recommended way to complete an HTTP-triggered Cloud Function. When passed an object, res.send automatically serializes it to JSON and sets the Content-Type response header to application/json, and it terminates the request. This works because Cloud Functions' HTTP handlers receive an Express-style response object, making this pattern highly reliable and idiomatic.

Why this answer

In Cloud Functions (Node.js runtime), the response is sent via the res (response) object. The correct method is res.send() or res.json(). res.send() can send JSON directly.

41
MCQmedium

An organization wants to use Cloud Storage to host a static website. The bucket name must match the domain name. They already own the domain 'example.com' and want to serve the site from 'www.example.com'. Which bucket name should they create?

A.example.com
B.www_example_com
C.example-com-bucket
D.www.example.com
AnswerD

The bucket must be named exactly www.example.com to serve content from that custom domain. When you create a bucket with this name, verify the domain in Cloud Console, and add a CNAME record from www.example.com to c.storage.googleapis.com, Cloud Storage automatically maps the bucket to the hostname. This exact match is required for HTTPS and proper static site hosting.

Why this answer

To host a website with a custom domain using Cloud Storage, you must use a bucket name that matches the domain (or subdomain). For 'www.example.com', the bucket must be named 'www.example.com'. For the apex domain, it would be 'example.com'.

42
Multi-Selecthard

A data engineering team wants to create a Cloud Storage bucket for storing sensitive analytics data. They require encryption at rest with customer-managed keys (CMEK) and want to restrict access to a specific service account. Which three steps are necessary?

Select 3 answers
A.Set the bucket's default encryption to use the KMS key
B.Enable uniform bucket-level access
C.Grant the service account roles/storage.objectAdmin on the bucket
D.Create a service account and download its JSON key
E.Create a Cloud KMS key ring and key in the same region as the bucket
AnswersA, C, E

Setting the bucket's default encryption to point at the KMS key is the step that activates customer-managed encryption for Cloud Storage. All objects uploaded after this change are automatically encrypted with the selected Cloud KMS key instead of Google-owned keys. Without this configuration, the key ring and key remain unused and the bucket continues using default encryption.

Why this answer

To use CMEK, you must create a Cloud KMS key ring and key, then configure the bucket to use that key. Access is controlled via IAM; granting the service account roles/storage.objectAdmin allows full object management. Note: The KMS key must be in the same region as the bucket.

43
MCQmedium

A data scientist wants to deploy a Python function that processes messages from a Pub/Sub topic whenever a new message arrives. The function should be stateless and run in a serverless environment. Which deployment command should be used?

A.gcloud run deploy my-function --source . --region us-central1 --trigger-topic my-topic
B.gcloud functions deploy my-function --runtime python39 --trigger-topic my-topic --entry-point my_entry --region us-central1
C.gcloud pubsub subscriptions create my-sub --topic my-topic --push-endpoint https://my-function-url
D.gcloud functions deploy my-function --runtime python39 --trigger-http --entry-point my_entry --region us-central1
AnswerB

gcloud functions deploy with --trigger-topic creates an event-driven Cloud Function subscribed to a Pub/Sub topic. The --runtime python39 specifies the Python 3.9 execution environment, --entry-point my_entry identifies the function name inside main.py to invoke, and --region sets the deployment location. This is the only valid command that directly deploys the function and wires it to the specified Pub/Sub topic.

Why this answer

Cloud Functions is serverless and can be triggered by Pub/Sub. The command 'gcloud functions deploy' with --trigger-topic creates a function that is triggered by messages on the specified topic.

44
Multi-Selecthard

An engineer needs to allow an external IP address (203.0.113.5) to access a Compute Engine instance that only has an internal IP. The instance is in a VPC with Cloud NAT. Which TWO steps are necessary to enable this access?

Select 2 answers
A.Grant the user the roles/iap.tunnelResourceAccessor IAM role on the instance
B.Set a firewall rule allowing ingress from the IP 203.0.113.5 to port 22
C.Modify the Cloud NAT to allow the external IP
D.Assign a public IP to the instance
E.Use 'gcloud compute start-iap-tunnel' to create a tunnel to the instance
AnswersA, E

Granting the roles/iap.tunnelResourceAccessor IAM role on the instance is the core authorization required for IAP TCP tunneling. This role ties a Google-authenticated user identity to a specific instance, letting them establish an encrypted tunnel through Cloud IAP to reach SSH or RDP even when the VM has only an internal IP. Without this IAM binding, the user cannot invoke `gcloud compute start-iap-tunnel` or the IAP API, making it the fundamental step for identity-aware access.

Why this answer

To access an internal-only instance from the internet, you need an IAP TCP forwarding tunnel (gcloud compute start-iap-tunnel) and the appropriate IAM role (roles/iap.tunnelResourceAccessor) to use IAP. Alternatively, you could use a bastion host, but IAP is cleaner.

45
MCQmedium

A company wants to allow unauthenticated HTTP invocations of a container deployed on Cloud Run. Which flag should be included in the 'gcloud run deploy' command?

A.--public
B.--no-authentication
C.--allow-unauthenticated
D.--auth-type public
AnswerC

The --allow-unauthenticated flag is the correct option because it explicitly grants the role roles/run.invoker to allUsers, enabling public access to the Cloud Run service. This flag is a required parameter when deploying a service that must respond to HTTP requests without any authentication, such as a public API or webhook. It overrides the default behavior, which denies access to unauthenticated users.

Why this answer

The '--allow-unauthenticated' flag allows unauthenticated invocations. By default, Cloud Run requires authentication.

46
MCQhard

A Cloud SQL for MySQL instance needs to be created with the following requirements: MySQL 8.0, db-n1-standard-2 tier, in us-central1, with root password 'secret'. Which command meets these requirements?

A.gcloud compute instances create my-instance --database-version MYSQL_8_0 --tier db-n1-standard-2 --region us-central1 --root-password secret
B.gcloud sql instances create my-instance --database-version MYSQL8 --tier n1-standard-2 --region us-central1 --password secret
C.gcloud sql instances create my-instance --database-version MYSQL_8_0 --tier db-n1-standard-2 --region us-central1 --root-password secret
D.gcloud sql instances create my-instance --database-version MYSQL_8_0 --machine-type db-n1-standard-2 --region us-central1 --root-password secret
AnswerC

This command correctly uses gcloud sql instances create with the supported database version MYSQL_8_0, the properly prefixed tier db-n1-standard-2, the target region us-central1, and the --root-password flag to set the initial root password. These are all valid and required parameters for provisioning a Cloud SQL for MySQL 8.0 instance from the command line.

Why this answer

The 'gcloud sql instances create' command with --database-version, --tier, --region, and --root-password correctly creates the instance.

47
Multi-Selectmedium

A company is deploying a microservice on Cloud Run. They want to ensure that the service can handle high traffic spikes by allowing multiple concurrent requests per container instance. They also want to minimize cold starts. Which two settings should they configure? (Choose two.)

Select 2 answers
A.Set the timeout to 900 seconds
B.Set CPU always on to true
C.Set min-instances to a value greater than 0 (e.g., 1)
D.Set max-instances to a high value
E.Set concurrency to a value higher than 1 (e.g., 80)
AnswersC, E

Setting min-instances to a value greater than 0, such as 1, instructs Cloud Run to keep at least one instance always running and fully initialized, so baseline traffic never experiences the latency penalty of a cold start. This pre-warmed instance is ready to serve immediately, eliminating the delay caused by pulling a container image and booting the runtime. Note that this approach incurs billing even when there is no traffic, and it only removes cold starts for the first instance; a sudden burst beyond that instance's concurrency can still trigger new cold starts.

Why this answer

Setting concurrency to a higher value (e.g., 80) allows each container instance to handle multiple requests simultaneously, improving throughput. Setting min-instances to a value greater than 0 keeps instances warm to reduce cold starts. Max-instances limits scaling but does not help with cold starts.

CPU always on keeps CPU allocated but does not directly affect cold starts. Timeout affects request duration, not concurrency or cold starts.

48
Multi-Selecthard

A DevOps engineer is creating a GKE cluster for a production workload that requires high availability and resilience to zone failures. They also need to deploy a stateless application that can scale based on CPU usage. Which two actions should they take? (Choose two.)

Select 2 answers
A.Enable node auto-repair on the node pool
B.Create a zonal cluster in a single zone
C.Set the deployment replicas to 1
D.Enable horizontal pod autoscaling on the deployment with CPU target utilization
E.Create a regional cluster with nodes in multiple zones
AnswersD, E

Horizontal Pod Autoscaler (HPA) continuously observes the average CPU utilization of the pods in a Deployment (via metrics-server) and automatically adjusts the `replicas` field to keep utilization near the configured target, e.g., 70%. This directly fulfills the stated need to scale the application based on load — when CPU usage rises, HPA adds pods; when it drops, HPA removes excess pods. Note that HPA is about pod-level elasticity and does not by itself provide zone resilience; to meet the production requirement fully, you would combine HPA with a regional multi-zone cluster so that scaled-out pods can be scheduled across failure domains.

Why this answer

A regional cluster spans multiple zones, providing high availability. An HPA scales pods based on CPU. A zonal cluster is not highly available.

Node auto-repair is for node health, not resilience to zone failure. Using a deployment with replicas is good, but the question asks for actions related to cluster creation and scaling.

49
MCQmedium

A developer wants to run a one-time query on a large dataset stored in Cloud Storage using BigQuery without loading the data into a table. Which feature should they use?

A.Use a BigQuery federated query with an external table definition
B.Create a permanent table and load the data using gcloud bq load
C.Use Cloud SQL to query the data via federated query
D.Use gcloud sql import to load data into BigQuery
AnswerA

A BigQuery federated query with an external table definition lets you query data that remains in Cloud Storage without loading it into BigQuery's managed storage. You define an external table pointing at files in GCS (CSV, JSON, Avro, Parquet, etc.) with optional schema auto-detection, and the query engine reads the source natively at query time. This matches a one-time analysis by eliminating the load job, copying no data, and charging only for the bytes scanned during execution.

Why this answer

BigQuery federated queries allow querying external data sources (like Cloud Storage) directly using external tables or the EXTERNAL_QUERY function. This avoids loading data.

50
MCQeasy

An engineer needs to create a GKE cluster with 3 nodes of machine type e2-medium in the us-central1 region. Which command should they use?

A.gcloud container clusters create my-cluster --num-nodes=3 --machine-type=e2-medium --region=us-central1
B.gcloud container clusters create my-cluster --num-nodes=3 --machine-type=e2-medium
C.gcloud container clusters create my-cluster --num-nodes=3 --machine-type=e2-medium --region=us-central1-a
D.gcloud container clusters create my-cluster --num-nodes=3 --machine-type=e2-medium --zone=us-central1-a
AnswerA

This command creates a regional GKE cluster in the us-central1 region, using --region rather than --zone. The --num-nodes=3 flag sets three e2-medium nodes in the cluster, and the regional scope means the control plane is replicated across the zones in us-central1, providing higher availability. This is the only option that correctly combines the required node specification with a regional location.

Why this answer

The correct command is 'gcloud container clusters create my-cluster --num-nodes=3 --machine-type=e2-medium --region=us-central1'. The --zone flag is for zonal clusters, not regional. The other options either use wrong zone or wrong flags.

51
Multi-Selectmedium

A company wants to deploy a new application on Google Cloud that requires a regional managed instance group with automatic scaling based on HTTP load. Which two resources must they create? (Choose TWO.)

Select 2 answers
A.Cloud Run service
B.GKE cluster
C.HTTP(S) Load Balancer
D.Instance template
E.Cloud Function
AnswersC, D

The HTTP(S) Load Balancer is a correct component because it provides a single anycast IP address that distributes incoming traffic across the backend Compute Engine instances in the managed instance group. It also performs health checks on those instances and automatically routes traffic only to healthy VMs, which is essential for a highly available application and is the standard external entry point for a MIG-based deployment.

Why this answer

To deploy a regional managed instance group (MIG) with autoscaling based on HTTP load, you need an instance template to define the VM configuration for the MIG, and an HTTP(S) Load Balancer to distribute traffic and provide the load metrics for autoscaling. Options C (HTTP(S) Load Balancer) and D (Instance template) are correct. Option A (Cloud Run) is for serverless containers, not for MIGs.

Option B (GKE cluster) is for Kubernetes. Option E (Cloud Function) is for serverless functions.

52
MCQeasy

You need to allow SSH access to a Compute Engine instance. Which method is the recommended way to manage SSH keys for multiple users?

A.Add SSH keys to the instance metadata.
B.Use gcloud compute ssh with the --ssh-key-file flag.
C.Enable OS Login and assign IAM roles to users.
D.Create a custom image with preconfigured SSH keys.
AnswerC

Enabling OS Login at the project or instance level, then assigning IAM roles such as roles/compute.osLogin or roles/compute.osAdminLogin to users, is the recommended pattern for SSH access. OS Login links the Linux account on the instance to the user's Google identity, automatically provisions a temporary SSH key when the user runs gcloud compute ssh, and allows instant revocation simply by removing the IAM policy binding.

Why this answer

OS Login is the recommended method for managing SSH access to Compute Engine instances, as it links SSH keys to user accounts and integrates with IAM.

53
MCQmedium

A team is using Terraform to manage Google Cloud infrastructure. They want to store Terraform state files in a remote backend that supports locking to prevent concurrent modifications. Which backend should they use?

A.Cloud Storage
B.Cloud Source Repositories
C.Cloud Shell
D.Cloud Bigtable
AnswerA

Cloud Storage is a fully supported Terraform remote backend for Google Cloud. When you configure a GCS bucket as a backend, Terraform stores the state file in the bucket, which lets multiple team members access the same state. The backend automatically uses an object lock to prevent concurrent writes, and you can enable bucket versioning to keep a history of state changes, which is essential for rollback and recovery. Additionally, the bucket can be secured with IAM policies, encryption at rest, and access logging.

Why this answer

Google Cloud Storage (GCS) is the recommended backend for Terraform on GCP. It supports state locking via object versioning and a lock mechanism (using the state lock table in a GCS bucket). Cloud Shell is not a backend.

Cloud Source Repositories is for source code. Bigtable is for NoSQL workloads.

54
MCQhard

A company wants to deploy a containerized application on Cloud Run that is built from source code in a local directory. They want Cloud Run to automatically build the container image using Cloud Build. Which command should be used?

A.gcloud run deploy my-service --source . --region us-central1
B.gcloud app deploy --source .
C.gcloud run deploy my-service --image . --region us-central1
D.gcloud builds submit --tag gcr.io/my-project/my-image . && gcloud run deploy my-service --image gcr.io/my-project/my-image
AnswerA

The --source flag tells gcloud to treat the current directory as source code, automatically invoking Cloud Build to containerize it using buildpacks before deploying to Cloud Run in the specified region. This single command combines the build and deploy steps, which is exactly what the requirement of a one-command deployment asks for. The service name 'my-service' is provided, and the region ensures the service is created in us-central1.

Why this answer

The 'gcloud run deploy' command with --source and --region flags tells Cloud Run to build and deploy from source. Cloud Build is invoked automatically.

55
MCQmedium

An engineer needs to view the logs generated by a Cloud Run service to troubleshoot a recent deployment. Which service should they use?

A.Cloud Monitoring
B.Cloud Logging
C.Error Reporting
D.Cloud Trace
AnswerB

Cloud Logging is the correct choice because it is the native, centralized log storage and retrieval service for Google Cloud, and Cloud Run automatically sends both request logs and platform logs to it. Application output written to stdout/stderr is also captured as structured logs. You can view these logs immediately in the Logs Explorer and filter them by resource type, severity, or labels.

Why this answer

Cloud Logging (formerly Stackdriver Logging) is the unified logging service for Google Cloud. Cloud Run logs are automatically sent to Cloud Logging.

56
MCQeasy

An engineer wants to create a regional GKE cluster with 3 nodes by default. Which command should be used?

A.gcloud container clusters create my-cluster --zone us-central1-a --num-nodes 3
B.gcloud container clusters create my-cluster --region us-central1 --num-nodes 3
C.gcloud container clusters create my-cluster --region us-central1 --nodes 3
D.gcloud compute clusters create my-cluster --region us-central1 --size 3
AnswerB

This is the standard way to create a regional GKE cluster. The --region flag designates a regional cluster where the control plane is replicated across three zones in that region, and nodes are spread across those zones (3 nodes per zone by default with --num-nodes 3). This provides higher availability and is exactly what the engineer needs.

Why this answer

The 'gcloud container clusters create' command with --region (not --zone) creates a regional cluster. --num-nodes specifies the number of nodes per zone.

57
MCQeasy

A developer wants to create a Compute Engine instance with the default Debian 11 image, a 50 GB boot disk, and in a specific subnet. Which command should be used?

A.gcloud compute instances create my-vm --image debian-11 --boot-disk-size 50 --subnet my-subnet
B.gcloud compute instances create my-vm --image-family debian-11 --image-project debian-cloud --disk-size 50GB --subnet my-subnet
C.gcloud compute instances create my-vm --image-family debian-11 --image-project debian-cloud --boot-disk-size 50GB --subnet my-subnet
D.gcloud compute instances create my-vm --image-family debian-11 --boot-disk-size 50 --subnet my-subnet
AnswerC

This is the only command that fully adheres to gcloud syntax: it uses --image-family debian-11 with --image-project debian-cloud to fetch the latest image from the public Debian project, --boot-disk-size 50GB to define a 50-gigabyte root disk with an explicit unit, and --subnet my-subnet to place the instance in the desired VPC subnet. The combination of these flags creates the instance successfully without requiring additional prompts or defaults. This is the recommended pattern for creating a VM from a public image family.

Why this answer

The command 'gcloud compute instances create' with flags --image-family, --image-project, --boot-disk-size, and --subnet correctly creates the instance with the specified configuration.

58
MCQmedium

A company has a managed instance group (MIG) with a fixed number of instances. They want to add an autoscaling policy that scales based on CPU utilization, with a target utilization of 60%. Which command should be used to update the MIG?

A.gcloud compute instance-groups managed set-autoscaling my-mig --region us-central1 --max-num-replicas 10 --target-cpu-utilization 0.6
B.gcloud compute instance-groups managed update my-mig --autoscaling --cpu-utilization 60
C.gcloud compute instance-groups managed configure-autoscaling my-mig --region us-central1 --target-cpu-utilization 0.6
D.gcloud compute instance-groups managed set-autoscaling my-mig --zone us-central1-a --max-num-replicas 10 --target-cpu-utilization 60
AnswerA

This is the correct command for enabling autoscaling on a regional managed instance group. The set-autoscaling verb properly applies the autoscaling policy, and the --region us-central1 flag matches the regional scope of the MIG. The --max-num-replicas 10 sets the upper limit, while --target-cpu-utilization 0.6 correctly specifies a 60% CPU utilization target as a decimal fraction.

Why this answer

The 'gcloud compute instance-groups managed set-autoscaling' command configures autoscaling for a MIG with the specified target CPU utilization.

59
MCQmedium

A data analyst wants to import a SQL dump file from a Cloud Storage bucket into an existing Cloud SQL database. Which command should they use?

A.gcloud sql instances import my-instance gs://my-bucket/dump.sql --database=mydb
B.gcloud sql import sql my-instance gs://my-bucket/dump.sql --database=mydb
C.gcloud sql import csv my-instance gs://my-bucket/dump.sql --database=mydb
D.gcloud sql databases import my-instance gs://my-bucket/dump.sql
AnswerB

This is the correct command. 'gcloud sql import sql' explicitly tells the Cloud SQL API that the source file is a SQL dump (typically generated by mysqldump or pg_dump). The arguments specify the instance name, the Cloud Storage URI of the dump file, and the target database using the --database flag. This syntax works for both MySQL and PostgreSQL instances and is the standard way to import SQL dump files.

Why this answer

The correct command is 'gcloud sql import sql <instance> gs://<bucket>/<file> --database=<db>'. This imports a SQL dump file. The other commands either use wrong syntax or wrong import type (csv for CSV files).

60
MCQhard

A DevOps engineer needs to deploy a containerized microservice to Cloud Run that processes messages from Pub/Sub. The service must authenticate to Google Cloud APIs using a service account. Which Cloud Run deployment command should they use to ensure the service uses a specific service account?

A.gcloud run deploy my-service --image gcr.io/my-project/my-image --service-account my-sa@my-project.iam.gserviceaccount.com --platform managed
B.gcloud run deploy my-service --image gcr.io/my-project/my-image --account my-sa@my-project.iam.gserviceaccount.com
C.gcloud run deploy my-service --image gcr.io/my-project/my-image --impersonate-service-account my-sa@my-project.iam.gserviceaccount.com
D.gcloud run deploy my-service --image gcr.io/my-project/my-image
AnswerA

Using the `--service-account` flag with `gcloud run deploy` explicitly assigns the specified IAM service account as the runtime identity for the Cloud Run service. This is the correct syntax because the flag is designed to set the service account that the container will run as, and `--platform managed` ensures the command targets Cloud Run (fully managed) rather than other platforms. The deployed service will inherit the IAM permissions of `my-sa@my-project.iam.gserviceaccount.com`, which is exactly what the DevOps engineer needs.

Why this answer

Cloud Run supports the --service-account flag to attach a specific service account. The --image flag specifies the container image. The other options either use incorrect flags (--account is for gcloud CLI user, not service account) or miss required flags.

61
MCQmedium

A company has a Cloud Run service that needs to access a Cloud SQL database. What is the recommended way to connect securely?

A.Use Cloud SQL Proxy by adding the Cloud SQL instance connection name to the Cloud Run service
B.Use a public IP for the Cloud SQL instance and whitelist the Cloud Run service's IP
C.Store database credentials in environment variables
D.Use VPC peering to connect Cloud Run to Cloud SQL
AnswerA

When you bind a Cloud Run service to a Cloud SQL instance by its connection name, the platform automatically injects and runs the Cloud SQL Auth Proxy as a sidecar container. The proxy connects to the database over an encrypted channel using either a private IP or a Unix socket, and it leverages IAM permissions to authorize the connection. This pattern avoids static IP management, network whitelisting, and manual secret handling, making it the officially recommended integration.

Why this answer

Cloud Run can use the Cloud SQL Proxy via a sidecar container or the built-in Cloud SQL connection using Unix sockets when the Cloud SQL client libraries are used. The recommended way is to use the Cloud SQL proxy (sidecar) or the Cloud SQL connector.

62
MCQmedium

A developer is deploying a containerized application on Cloud Run. The application needs to be invoked by external HTTPS requests without requiring authentication. Which flag should be included in the 'gcloud run deploy' command?

A.--invoker=public
B.--allow-unauthenticated
C.--ingress=internal
D.--no-allow-unauthenticated
AnswerB

The `--allow-unauthenticated` flag is the correct way to enable public HTTPS access to a Cloud Run service. When set at deploy time, Cloud Run binds the IAM role `roles/run.invoker` to the special `allUsers` principal, allowing any client to invoke the service without providing credentials. This directly satisfies the requirement of making the containerized app reachable from the internet.

Why this answer

The --allow-unauthenticated flag makes the Cloud Run service publicly accessible. By default, Cloud Run requires authentication via IAM. Adding this flag grants the 'run.invoker' role to allUsers.

63
MCQmedium

An engineer wants to deploy a Python function that processes messages from a Pub/Sub topic. The function should be triggered whenever a message is published to the topic. Which command should the engineer use to deploy the function?

A.gcloud functions deploy my-function --runtime python39 --trigger-http --entry-point main --region=us-central1
B.gcloud functions deploy my-function --runtime python39 --trigger-topic my-topic --entry-points main --region=us-central1
C.gcloud functions deploy my-function --runtime python39 --trigger-topic my-topic --entry-point main --region=us-central1
D.gcloud functions deploy my-function --runtime python39 --trigger-bucket my-bucket --entry-point main --region=us-central1
AnswerC

This is the correct command because --trigger-topic my-topic binds the function to Pub/Sub, causing it to be invoked every time a message is published to that topic. The --entry-point main identifies the Python callable in the code, while --runtime python39 specifies the runtime. It correctly deploys a background Cloud Function without exposing an HTTP endpoint.

Why this answer

To deploy a Cloud Function triggered by a Pub/Sub topic, use gcloud functions deploy with --trigger-topic. Option C is correct. Option A uses --trigger-http for HTTP triggers.

Option B uses --trigger-topic but misspells --entry-point as --entry-points. Option D uses --trigger-bucket for Cloud Storage events.

64
MCQhard

A team is deploying a microservice to Cloud Run that needs to process messages from Pub/Sub. The service should only be invocable by Pub/Sub push deliveries, not by unauthenticated HTTP requests. What should the team do?

A.Deploy with --allow-unauthenticated and set up a Pub/Sub subscription with OIDC token audience
B.Deploy with --no-allow-unauthenticated and create a VPC connector to allow Pub/Sub internal traffic
C.Deploy with --no-allow-unauthenticated and configure the Pub/Sub subscription to use a service account that has the roles/run.invoker role on the Cloud Run service
D.Use Cloud Functions instead, which is more secure for Pub/Sub triggers
AnswerC

Deploying with `--no-allow-unauthenticated` enforces that only authenticated requests carrying a valid OIDC token are accepted by the Cloud Run service. When the Pub/Sub subscription is configured with a service account that has the `roles/run.invoker` role on the service, Pub/Sub uses that identity to mint an OIDC token with the correct audience, and Cloud Run recognizes the token as authorized. This is the recommended secure pattern for triggering Cloud Run from Pub/Sub.

Why this answer

To restrict invocation to only Pub/Sub, the Cloud Run service must require authentication and the Pub/Sub subscription must be configured to use a service account to push. The --no-allow-unauthenticated flag ensures only authenticated requests are accepted, and the Pub/Sub subscription's push endpoint must be set with the service's URL and use a service account with the run.invoker role.

65
MCQhard

A team wants to use Cloud Run to deploy a container that processes messages from a Pub/Sub topic. The container is stateless and the workload is expected to have irregular traffic spikes with high concurrency. Which scaling configuration is most appropriate?

A.Set min-instances to 0 and max-instances to 1000 with concurrency of 1
B.Set min-instances to 0 and max-instances to 100 with concurrency of 80
C.Set min-instances to 10 and max-instances to 100 with concurrency of 1
D.Set min-instances to 1 and max-instances to 100 with concurrency of 1
AnswerB

Min-instances 0 allows scaling to zero when idle, max 100 handles spikes, high concurrency maximizes throughput.

Why this answer

Cloud Run can set a maximum number of concurrent requests per container instance. For Pub/Sub processing, setting max-instances can control cost, and the CPU is always allocated during request processing. The key is to allow multiple concurrent requests to handle spikes efficiently.

66
MCQmedium

An engineer deployed a new version of their application on GKE using a Deployment. Users report that the new version has a bug. The engineer wants to quickly revert to the previous version. How can they achieve this?

A.Scale the deployment to zero and then scale back up
B.Run kubectl delete deployment and re-apply the old manifest
C.Run kubectl rollout undo deployment/<deployment-name>
D.Run kubectl rollout history deployment/<deployment-name>
AnswerC

`kubectl rollout undo deployment/<deployment-name>` instructs the Deployment controller to revert to the previous revision by restoring the prior Pod template and rolling it out with the same gradual scaling strategy—creating a new ReplicaSet while terminating the current one in a controlled fashion. This preserves availability because the controller scales up the new/old ReplicaSet before scaling down the current one. The command is the canonical, declarative way to undo a bad deployment with minimal downtime.

Why this answer

Kubernetes Deployments support rollbacks using 'kubectl rollout undo'. The command automatically reverts to the previous revision. Deleting and recreating the Deployment would require re-creating from the previous manifest. 'kubectl rollout history' shows history but doesn't roll back.

Scaling down then up does not revert the version.

Ready to test yourself?

Try a timed practice session using only Deploying and Implementing a Cloud Solution questions.