A cloud administrator needs to configure their local terminal environment to manage an existing Google Kubernetes Engine (GKE) cluster named `prod-cluster` located in zone `us-central1-a` using `kubectl`. Which command should the administrator run to fetch cluster credentials and update the local `kubeconfig` file?
- gcloud container clusters get-credentials prod-cluster --zone us-central1-aAnswer
- Bkubectl config set-cluster prod-cluster --zone us-central1-a
- Cgcloud container clusters describe prod-cluster --zone us-central1-a
- Dgcloud iam service-accounts keys create cluster-key.json --iam-account [email protected]
Answer
The command `gcloud container clusters get-credentials prod-cluster --zone us-central1-a` is the standard tool used to populate the local `kubeconfig` file with cluster endpoint details and authentication tokens.
To manage a GKE cluster with `kubectl`, the administrator must retrieve the cluster's endpoint and authentication credentials using `gcloud container clusters get-credentials <cluster-name> --zone <zone>`. This updates the local `kubeconfig` entry automatically.
Step-by-Step Solution
Key Concept
Fetching GKE cluster credentials for kubectl authentication