Question

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

A developer has created a Google Kubernetes Engine (GKE) cluster to host an application. Before running `kubectl` commands to manage workloads on the cluster, the developer must retrieve cluster access credentials and configure the local command-line environment. Which `gcloud` command should the developer run to update the local `kubeconfig` file with these credentials?

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

Answer

Execute `gcloud container clusters get-credentials my-cluster --zone us-central1-a` to automatically populate the local kubeconfig file with cluster endpoints and security credentials.
Executing `gcloud container clusters get-credentials` authenticates against the specified GKE cluster and writes the required certificate authority data, cluster endpoint, and user token into the local `kubeconfig` file. This establishes the active context needed for `kubectl` to communicate with the cluster API server.

Step-by-Step Solution

1
Identify the CLI tool required to authenticate kubectl with a GKE cluster.
The gcloud container component provides cluster credential integration.
kubectl requires an active context entry containing the cluster API server endpoint and authorization certificate.
2
Select the exact command designed to fetch cluster credentials.
`gcloud container clusters get-credentials` updates `~/.kube/config`.
This command generates authentication entries so kubectl commands seamlessly talk to the GKE control plane.

Key Concept

Configuring local kubectl context using gcloud container clusters get-credentials
Rate this question