Soru

Zorluk: OrtaDeploying and Managing Google Kubernetes Engine (GKE) Clusters and Workloads

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?

  1. gcloud container clusters get-credentials prod-app-cluster --region=us-central1Cevap
  2. B
    gcloud config set container/cluster prod-app-cluster
  3. C
    gcloud container node-pools create spot-pool --cluster=prod-app-cluster --enable-spot --region=us-central1
  4. D
    gcloud 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

1
Identify why kubectl fails with a localhost:8080 error.
Recognize that kubectl defaults to localhost:8080 when no valid target API server context exists in the local ~/.kube/config file.
Before kubectl can target a remote GKE cluster, local credentials and context entries must be populated.
2
Determine the correct gcloud CLI command to populate cluster credentials.
Select `gcloud container clusters get-credentials` along with the cluster name and region flag.
This command generates security tokens, fetches cluster endpoint IPs, and constructs the current-context entry inside kubeconfig.

Anahtar Kavram

Fetching GKE cluster credentials to configure local kubectl context
Bu soruyu puanla