Question

Difficulty: HardDeploying and Managing Google Kubernetes Engine (GKE) Clusters and Workloads

A DevOps engineer is tasked with deploying an API gateway workload defined in `gateway-deployment.yaml` to an existing regional GKE cluster named `api-gateway-prod` located in the `europe-west1` region. When the engineer executes `kubectl apply -f gateway-deployment.yaml` from a freshly provisioned administration workstation, the operation fails with an authorization error because local kubeconfig parameters are missing. Which command must the engineer execute to generate the cluster authentication credentials and update the local kubeconfig context so `kubectl` can successfully interact with the cluster?

  1. gcloud container clusters get-credentials api-gateway-prod --region europe-west1Answer
  2. B
    gcloud config set container/cluster api-gateway-prod
  3. C
    gcloud container node-pools update default-pool --cluster api-gateway-prod --region europe-west1 --enable-autoupgrade
  4. D
    kubectl config set-cluster api-gateway-prod --server=https://container.googleapis.com

Answer

The command 'gcloud container clusters get-credentials api-gateway-prod --region europe-west1' should be executed to fetch the API server credentials and update the local kubeconfig configuration.
The correct command utilizes the 'gcloud container clusters get-credentials' command with the appropriate cluster name and '--region' flag to download the necessary authentication credentials and API endpoint metadata directly into the user's local kubeconfig file, authorizing subsequent 'kubectl' commands.

Step-by-Step Solution

1
Identify the authentication mechanism between local workstations and GKE clusters.
Recognize that kubectl relies on a valid context entry in ~/.kube/config containing cluster endpoint IP address, CA certificate, and access token.
Without updated kubeconfig entries, kubectl cannot target or authenticate against the remote GKE control plane.
2
Select the correct gcloud tool command for GKE credential retrieval.
Use 'gcloud container clusters get-credentials' combined with the cluster name and region flag.
This command automatically generates authenticating tokens via Google Cloud IAM and populates local kubeconfig entries.
3
Apply the Kubernetes workload manifest.
Execute 'kubectl apply -f gateway-deployment.yaml'.
Once the kubeconfig context is populated, kubectl commands successfully route to the target GKE cluster.

Key Concept

GKE Cluster Credential Retrieval and Kubeconfig Management
Estimated Time:2m 0s
Rate this question