Question

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

A DevOps engineer has created a new Google Kubernetes Engine (GKE) cluster named `app-cluster` in the `us-west1-a` zone. Before deploying workloads using `kubectl`, the engineer must configure local command-line credentials for this cluster. Which command should the engineer execute to populate the local `kubeconfig` file?

  1. gcloud container clusters get-credentials app-cluster --zone us-west1-aAnswer
  2. B
    gcloud config set container/cluster app-cluster
  3. C
    gcloud container clusters describe app-cluster --zone us-west1-a
  4. D
    gcloud compute instances get-credentials app-cluster --zone us-west1-a

Answer

The command `gcloud container clusters get-credentials app-cluster --zone us-west1-a` is correct because it downloads the cluster endpoint and authentication credentials required by `kubectl` to interact with the GKE cluster.
Executing `gcloud container clusters get-credentials app-cluster --zone us-west1-a` retrieves the cluster endpoint and authentication credentials from Google Cloud and updates the local `kubeconfig` file, allowing `kubectl` commands to target the specified cluster.

Step-by-Step Solution

1
Identify the CLI tool responsible for managing GKE cluster authentication contexts.
Recognize that `gcloud container clusters` is used for GKE cluster lifecycle and credential tasks.
Before `kubectl` can communicate with a GKE cluster control plane, a valid context must exist in `~/.kube/config`.
2
Select the sub-command specifically designated for downloading cluster credentials.
Identify `get-credentials` along with the mandatory cluster name and zone flag.
Executing `gcloud container clusters get-credentials` writes the necessary certificate authority and auth token configuration into the local `kubeconfig`.

Key Concept

Fetching GKE cluster authentication credentials for kubectl configuration
Rate this question