You are preparing a new non-interactive build worker VM that will deploy application images to several Google Kubernetes Engine (GKE) clusters in different projects. You have already installed the Google Cloud SDK on the VM. The build script must:
Call kubectl commands whose version stays aligned with the Cloud SDK installation.
Authenticate with a dedicated service account rather than a human user.
Populate kubeconfig automatically for each target cluster at runtime. Which installation and configuration steps will satisfy all of these requirements?
Download the kubectl binary release that matches the cluster version and copy it to /usr/local/bin; use gcloud config set project and then manually add the cluster endpoint to kubeconfig.
Install kubectl with apt from the Kubernetes upstream repository and manually create a kubeconfig file that stores the cluster's basic-auth user name and password.
Skip kubectl installation on the VM and execute the build script inside Cloud Shell, which already contains kubectl and cluster credentials.
Run gcloud components install kubectl, authenticate the VM with gcloud auth activate-service-account, and call gcloud container clusters get-credentials for each cluster before running kubectl commands.
Using the Cloud SDK component manager to install kubectl guarantees that the kubectl binary is kept at the same release level as gcloud when the SDK is updated, removing manual version tracking. Authenticating once with gcloud auth activate-service-account stores short-lived OAuth tokens for the service account, and gcloud container clusters get-credentials writes the correct cluster endpoint and a token-based user entry to kubeconfig without embedding static user credentials. This fulfils the alignment, non-interactive authentication, and automatic configuration goals. Installing kubectl from an external package repository, downloading the standalone binary, or relying on Cloud Shell would either break version parity, still require manual kubeconfig editing, or not run inside the build worker VM.
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 `gcloud components install kubectl`?
Open an interactive chat with Bash
How does `gcloud container clusters get-credentials` work?
Open an interactive chat with Bash
What is a service account and why is it used here?
Open an interactive chat with Bash
What is gcloud auth activate-service-account?
Open an interactive chat with Bash
How does gcloud container clusters get-credentials work?
Open an interactive chat with Bash
Why use gcloud components install kubectl instead of other installation methods?
Open an interactive chat with Bash
GCP Associate Cloud Engineer
Planning and implementing 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 .