A site reliability engineer is setting up a freshly imaged workstation to manage an active Google Kubernetes Engine (GKE) Standard cluster named `prod-app-cluster` located in region `us-central1`. When attempting to run `kubectl get pods`, the command fails with an error indicating that the connection to `localhost:8080` was refused because the local environment context is unconfigured. Which `gcloud` command must the engineer execute to retrieve cluster credentials and update the local `kubeconfig` file?
- gcloud container clusters get-credentials prod-app-cluster --region=us-central1Cevap
- Bgcloud config set container/cluster prod-app-cluster
- Cgcloud container node-pools create spot-pool --cluster=prod-app-cluster --enable-spot --region=us-central1
- Dgcloud container clusters update prod-app-cluster --enable-autopilot --region=us-central1
Cevap
The command `gcloud container clusters get-credentials prod-app-cluster --region=us-central1` must be executed to update the local kubeconfig file.
Executing the command `gcloud container clusters get-credentials prod-app-cluster --region=us-central1` authenticates to Google Cloud, retrieves the cluster endpoint certificates, and writes an authenticated context entry directly into the local `kubeconfig` file so that `kubectl` can target the cluster.
Adım Adım Çözüm
Anahtar Kavram
Fetching GKE cluster credentials to configure local kubectl context