Question

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

An administrator needs to configure a local management workstation to interact with a newly created Google Kubernetes Engine (GKE) cluster named `finance-app-cluster` in the `us-central1-a` zone. Which of the following commands are required to fetch the cluster credentials for `kubectl` and verify the running workloads? (Select TWO.)

  1. Execute `gcloud container clusters get-credentials finance-app-cluster --zone us-central1-a` to update the local kubeconfig file.Answer
  2. B
    Execute `gcloud config set container/cluster finance-app-cluster` to establish the kubectl authentication context.
  3. Execute `kubectl get pods` to list the currently running Kubernetes workload pods in the cluster.Answer
  4. D
    Execute `gcloud compute instances list --cluster finance-app-cluster` to establish direct API credentials for kubectl.

Answer

The correct commands are executing `gcloud container clusters get-credentials finance-app-cluster --zone us-central1-a` to populate the local kubeconfig file and executing `kubectl get pods` to inspect the workload pods.
To manage a GKE cluster via kubectl, credentials must first be fetched using `gcloud container clusters get-credentials`, specifying the cluster name and location (zone or region). Once configured, standard Kubernetes tools like `kubectl get pods` interact directly with the cluster API server.

Step-by-Step Solution

1
Fetch the GKE cluster credentials using the Google Cloud CLI.
The local `~/.kube/config` file is created or updated with the cluster endpoint and API authentication tokens.
kubectl requires active cluster context and authentication credentials before sending requests to the API server.
2
Run kubectl commands to query cluster resources.
Kubectl retrieves and displays the workload pods running in the specified cluster namespace.
`kubectl get pods` uses the context stored in kubeconfig to communicate with the GKE control plane.

Key Concept

Deploying and Managing GKE Clusters and Workloads - Authenticating kubectl and querying GKE resources
Rate this question