Your team operates a Java web service in a GKE cluster. Users report brief latency spikes during traffic peaks, and you suspect a CPU-intensive code path is responsible. Monitoring and Logging are already enabled on the cluster. Which action will let you begin collecting production CPU profiles in Cloud Profiler with the least disruption to the running Pods?
Convert the cluster to Autopilot mode and set an --enable-cloud-profiler flag on the control plane so profiles are gathered for all workloads.
Add the Cloud Profiler Java agent to the application's startup command and grant the Pod's service account the Cloud Profiler Agent IAM role.
Enable the Cloud Profiler API in the project and rely on the Ops Agent already running on each node to upload CPU samples automatically.
Deploy a DaemonSet that periodically SSHes into each node, captures stack traces, and pushes them to Cloud Storage for later analysis.
Cloud Profiler does not gather data automatically from GKE workloads. The application process itself must load the Cloud Profiler language agent so that it can sample stack traces and send them to the Profiler backend. In GKE, the agent typically is added by including the Profiler Java agent JAR and setting the appropriate startup options or environment variables. In addition, the Kubernetes service account used by the Pods must have the roles/cloudprofiler.agent IAM role so the agent can write profile data. Simply enabling the API or relying on the Ops Agent running on the nodes does not activate profiling for in-process code, and there is no cluster-level flag or external trace-collection script that will populate Cloud Profiler.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What is Cloud Profiler and why is it used?
Open an interactive chat with Bash
How do I integrate the Cloud Profiler Java agent with my application in GKE?
Open an interactive chat with Bash
Why can't the Ops Agent or a DaemonSet handle profiling in GKE?
Open an interactive chat with Bash
What is the Cloud Profiler Java agent and how does it work?
Open an interactive chat with Bash
Why does the Pod's service account need the Cloud Profiler Agent IAM role?
Open an interactive chat with Bash
Why can't the Ops Agent or a DaemonSet collect CPU profiles for GKE workloads?
Open an interactive chat with Bash
GCP Associate Cloud Engineer
Ensuring successful operation of a cloud solution
Your Score:
Report Issue
Bash, the Crucial Exams Chat Bot
AI Bot
Loading...
Loading...
Loading...
Pass with Confidence.
IT & Cybersecurity Package
You have hit the limits of our free tier, become a Premium Member today for unlimited access.
Military, Healthcare worker, Gov. employee or Teacher? See if you qualify for a Community Discount.
Monthly
$19.99 $11.99
$11.99/mo
Billed monthly, Cancel any time.
$19.99 after promotion ends
3 Month Pass
$44.99 $26.99
$8.99/mo
One time purchase of $26.99, Does not auto-renew.
$44.99 after promotion ends
Save $18!
MOST POPULAR
Annual Pass
$119.99 $71.99
$5.99/mo
One time purchase of $71.99, Does not auto-renew.
$119.99 after promotion ends
Save $48!
BEST DEAL
Lifetime Pass
$189.99 $113.99
One time purchase, Good for life.
Save $76!
What You Get
All IT & Cybersecurity Package plans include the following perks and exams .