Soru

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

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`?

  1. gcloud container clusters get-credentials payment-prod-cluster --region europe-west3Cevap
  2. B
    gcloud config set container/cluster payment-prod-cluster
  3. C
    gcloud container node-pools update payment-prod-cluster --region europe-west3
  4. D
    kubectl config set-cluster payment-prod-cluster --region europe-west3

Cevap

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.

Adım Adım Çözüm

1
Identify the missing requirement for kubectl execution
Recognize that kubectl needs an updated kubeconfig file containing valid access tokens and the cluster control plane IP address.
Installing kubectl alone does not configure network targets or credentials for specific GKE clusters.
2
Select the proper gcloud command for GKE authentication configuration
Use `gcloud container clusters get-credentials` along with cluster name and location flags.
This command communicates with the GKE API to construct the kubeconfig context automatically.
3
Verify regional flag requirement
Specify `--region europe-west3` because `payment-prod-cluster` is a regional cluster rather than a zonal cluster.
Omitting location flags or using `--zone` for a regional cluster causes gcloud credential retrieval to fail.

Anahtar Kavram

Configuring kubectl context for Google Kubernetes Engine using gcloud
Tahmini Süre:1m 30s
Bu soruyu puanla