A DevOps engineer needs to deploy a microservice workload manifest to an existing regional Google Kubernetes Engine (GKE) cluster named `payment-prod-cluster` located in the `europe-west3` region. The engineer is logged into a fresh management virtual machine where the Google Cloud SDK (`gcloud`) and `kubectl` are installed, and the user is authenticated to GCP with proper IAM permissions. However, executing `kubectl apply -f deployment.yaml` fails because `kubectl` lacks the context to communicate with the cluster. Which command must the engineer run to fetch cluster credentials and update `kubeconfig` for `payment-prod-cluster`?
- gcloud container clusters get-credentials payment-prod-cluster --region europe-west3Answer
- Bgcloud config set container/cluster payment-prod-cluster
- Cgcloud container node-pools update payment-prod-cluster --region europe-west3
- Dkubectl config set-cluster payment-prod-cluster --region europe-west3
Answer
The command `gcloud container clusters get-credentials payment-prod-cluster --region europe-west3` must be run to fetch authentication credentials and endpoint information from Google Cloud and write them into the local `kubeconfig` file.
Executing `gcloud container clusters get-credentials payment-prod-cluster --region europe-west3` queries the GKE API for the cluster's endpoint and certificate authority data, generates an authentication token, and writes an entry into the local `$HOME/.kube/config` file. This switches `kubectl`'s active context to `payment-prod-cluster`, enabling deployment commands to succeed.
Step-by-Step Solution
Key Concept
Configuring kubectl context for Google Kubernetes Engine using gcloud
Estimated Time:1m 30s