A DevOps engineer receives access to a newly provisioned Google Kubernetes Engine (GKE) Standard cluster named `analytics-cluster` located in the `us-east1-b` zone. When running `kubectl get nodes`, the command fails with an error indicating that connection to `localhost:8080` was refused because the local environment lacks cluster endpoint credentials. Which `gcloud` command must the engineer execute to generate the necessary `kubeconfig` entry and enable `kubectl` management?
- gcloud container clusters get-credentials analytics-cluster --zone us-east1-bAnswer
- Bgcloud container clusters update analytics-cluster --enable-autoscaling --zone us-east1-b
- Cgcloud iam service-accounts keys create credentials.json --iam-account [email protected]
- Dkubectl config set-cluster analytics-cluster --server us-east1-b
Answer
The command `gcloud container clusters get-credentials analytics-cluster --zone us-east1-b` must be executed to populate the local `kubeconfig` file with the GKE cluster control plane endpoint and authentication credentials.
To manage a GKE cluster using `kubectl`, administrative credentials and endpoint IP information must be downloaded to the local environment. Running `gcloud container clusters get-credentials <cluster-name> --zone <zone>` obtains the cluster API server certificate and authentication token, updating `~/.kube/config` so `kubectl` can target the cluster.
Step-by-Step Solution
Key Concept
GKE Cluster Credential Fetching via gcloud CLI