Prepare and test your skills

Prepare and test your skills

Free sample question with answers and detailed explanation below. The Professional Cloud Developer practice bank has an additional 608 practice questions.Try 10 free realistic questions: instant score, no credit card, and no account required.
A development team is deploying a stateless API service on a Google Kubernetes Engine (GKE) Standard cluster that has Workload Identity Federation for GKE and Google Cloud Managed Service for Prometheus enabled. CPU utilization does not accurately reflect workload demand, so the team needs to configure the Horizontal Pod Autoscaler (HPA) to scale based on an application-specific signal.
Requirements for the scaling setup:
app_request_queue_depth exposed on port 8080 at /metrics.orders-api Deployment using the Custom Metrics Stackdriver Adapter based on the average metric value per Pod.Which configuration should the team implement?
prometheus.io/scrape: "true" annotations to the orders-api Pod template instead of creating a PodMonitoring resource, convert app_request_queue_depth to a Prometheus Counter metric, install the Custom Metrics Stackdriver Adapter using default RBAC only, and configure an HPA referencing the raw metric name.This option relies on legacy prometheus.io/scrape Pod annotations for discovery, changes the application metric from a Gauge to a Counter, omits the Google Cloud IAM binding for Workload Identity, and references the unformatted metric name inside the HPA manifest.
prometheus.io/scrape annotations. Without a PodMonitoring (or ClusterPodMonitoring) custom resource, no custom application metrics are ingested into Cloud Monitoring.Gauge, because a Gauge represents a point-in-time value that can increase or decrease (such as queue depth). A Counter increases monotonically and only resets on restart, making it unsuitable for direct per-Pod AverageValue scaling.roles/monitoring.viewer to the custom-metrics-stackdriver-adapter service account, Cloud Monitoring queries fail with permission errors.prometheus.googleapis.com|<metric>|gauge format rather than the raw Prometheus name.PodMonitoring provides namespace-scoped scrape configuration for Managed Service for Prometheus.You were using a self-managed upstream Prometheus server configured for annotation-based scraping along with prometheus-adapter executing a PromQL rate() expression over a Counter metric.
PodMonitoring resource to scrape port 8080 at /metrics, install the Custom Metrics Stackdriver Adapter, bind the roles/monitoring.viewer IAM role to the custom-metrics-stackdriver-adapter Kubernetes service account, and create an autoscaling/v2 HorizontalPodAutoscaler referencing prometheus.googleapis.com|app_request_queue_depth|gauge with type: Pods and AverageValue.Google Cloud Managed Service for Prometheus collects Prometheus-format metrics from GKE workloads without requiring operators to manage Prometheus servers at scale. The Custom Metrics Stackdriver Adapter bridges Cloud Monitoring and the Kubernetes Custom Metrics API, allowing the Horizontal Pod Autoscaler (HPA) controller to read application-specific signals and adjust Pod replicas dynamically.
PodMonitoring custom resource (monitoring.googleapis.com/v1) instructs the managed Prometheus collector to scrape the orders-api Pods on port 8080 at the /metrics path on a recurring interval. Once ingested into Cloud Monitoring, the Prometheus Gauge metric is stored using the prometheus.googleapis.com/<metric_name>|gauge naming convention.custom-metrics-stackdriver-adapter Kubernetes service account in the custom-metrics namespace. Granting roles/monitoring.viewer to its Workload Identity principal allows the adapter to securely query Cloud Monitoring without exporting long-lived service account key files.autoscaling/v2 HorizontalPodAutoscaler specifying type: Pods, the metric name prometheus.googleapis.com|app_request_queue_depth|gauge, and target.type: AverageValue computes the desired replica count from the average queue depth across all active Pods.app_request_queue_depth responds directly to request backlog rather than lagging CPU metrics.autoscaling/v2 manifests work seamlessly with Cloud Monitoring custom metrics.This configuration follows the supported Google Cloud architecture for single-metric Pod autoscaling, ensuring secure authentication, proper metric ingestion, and accurate replica scaling without introducing conflicting Kubernetes API registrations.
prometheus-adapter in the cluster to bridge Cloud Monitoring and Kubernetes metrics, deploy a PodMonitoring resource, and configure an autoscaling/v2 HorizontalPodAutoscaler using type: Resource targeting app_request_queue_depth.This approach tries to deploy two separate metrics adapters—the Custom Metrics Stackdriver Adapter and the third-party prometheus-adapter—side by side in the same GKE cluster, while configuring the Horizontal Pod Autoscaler (HPA) to evaluate the application metric using the type: Resource metric specification.
prometheus-adapter register the exact same Kubernetes APIService objects (v1beta1.custom.metrics.k8s.io, v1beta2.custom.metrics.k8s.io, and v1beta1.external.metrics.k8s.io). Running both adapters in a single cluster causes overlapping resource definitions and errors such as FailedGetObjectMetric, preventing the HPA from querying metrics reliably.autoscaling/v2 HPA manifest, type: Resource is strictly reserved for core Kubernetes compute resources (cpu and memory) reported by the Metrics Server. Application-specific signals emitted by Pods must use type: Pods (or type: External for external or aggregated PromQL metrics).roles/monitoring.viewer to the adapter's service account, which is mandatory when Workload Identity Federation for GKE is active.APIService provider per custom or external metrics API group.type: Resource cannot resolve Prometheus or Cloud Monitoring custom metric names.prometheus-adapter alongside the Stackdriver Adapter requires deleting colliding APIService resources if switching adapters.No single cluster should run both adapters simultaneously; you must choose one adapter solution (Custom Metrics Stackdriver Adapter for individual metrics, or prometheus-adapter for multi-metric PromQL expressions) and use type: Pods or type: External in the HPA specification.
prometheus-adapter configured to query Cloud Monitoring directly without deploying the Prometheus frontend UI proxy, define a .seriesQuery rule using a regular expression matcher on app_request_queue_depth, omit namespace and cluster filters from the PromQL query, and configure an HPA with type: External.The third-party prometheus-adapter enables Kubernetes HPA scaling using arbitrary PromQL queries, including expressions that combine multiple metrics. However, integrating prometheus-adapter with Google Cloud Managed Service for Prometheus enforces strict architectural and query requirements that this option violates.
prometheus-adapter cannot query Cloud Monitoring directly on its own without a compatible Prometheus API endpoint. Queries must be routed through the Prometheus frontend UI proxy (--prometheus-url=http://frontend.<namespace>.svc:9090/), which also requires Workload Identity authorization with roles/monitoring.viewer..seriesQuery: When using prometheus-adapter with Managed Service for Prometheus, regular expression matchers (=~ or !~) are not supported on metric names inside the .seriesQuery field of the rules configuration; metric names must be fully specified.namespace or cluster filters causes the HPA to aggregate identically named metrics from other clusters or namespaces, leading to inaccurate scaling.prometheus-adapter.prometheus-adapter requires the Prometheus frontend UI proxy to translate PromQL queries against Cloud Monitoring..seriesQuery rules.cluster and namespace label filters to isolate workload signals.You needed to scale on a complex PromQL expression combining multiple metrics using prometheus-adapter, deployed the Prometheus frontend UI proxy with roles/monitoring.viewer, specified exact metric names in .seriesQuery, and included namespace and cluster filters.
Answer them yourself and get your score the moment you finish. No account needed.
Full access includes
Keep the momentum going with these hand-picked practice scenarios
Last updated Validated