Question

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

A newly onboarded developer needs to administer workloads on a regional Google Kubernetes Engine (GKE) cluster named `ecommerce-app` located in `us-east1`. The developer has installed `kubectl` and the `gcloud` CLI, but running `kubectl` commands fails because the cluster context is not yet configured locally. Which TWO actions should the developer perform to authenticate `kubectl` to the cluster and deploy the workload manifest `deployment.yaml`?

  1. Run gcloud container clusters get-credentials ecommerce-app --region us-east1 to generate the local kubeconfig context.Answer
  2. Execute kubectl apply -f deployment.yaml to deploy the workload to the target GKE cluster.Answer
  3. C
    Run gcloud config set container/cluster ecommerce-app to set the local Kubernetes context.
  4. D
    Re-create the GKE cluster using Autopilot mode because kubectl credentials cannot be generated for Standard clusters.

Answer

The developer must run gcloud container clusters get-credentials to populate local kubeconfig credentials, and then execute kubectl apply -f deployment.yaml to deploy the manifest.
To administer any GKE cluster with kubectl, developers must first run gcloud container clusters get-credentials with the cluster name and region or zone. This command retrieves authentication tokens and updates the local kubeconfig file. After credentials are updated, running kubectl apply -f deployment.yaml successfully communicates with the GKE control plane to create the specified workload.

Step-by-Step Solution

1
Fetch cluster credentials using the gcloud CLI
Local kubeconfig file is updated with cluster API endpoint and authentication entries
kubectl requires authentication tokens and endpoint certificates from GCP to communicate with the GKE control plane.
2
Deploy the application manifest using kubectl
The workload resources defined in deployment.yaml are created on the GKE cluster
With an active cluster context configured in kubeconfig, kubectl commands target the GKE cluster directly.

Key Concept

Fetching GKE cluster credentials using gcloud to configure local kubectl context
Rate this question