Question

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

A cloud engineer needs to configure a local command-line environment and deploy a containerized application to an existing Google Kubernetes Engine (GKE) cluster. In what sequential order should the engineer execute these tasks from start to finish?

  1. 1Set the active GCP project context using `gcloud config set project [PROJECT_ID]`.
  2. 2Fetch cluster endpoint and credentials into kubeconfig using `gcloud container clusters get-credentials [CLUSTER_NAME] --zone [ZONE]`.
  3. 3Verify cluster connection and context setup using `kubectl cluster-info`.
  4. 4Apply the workload configuration manifest using `kubectl apply -f deployment.yaml`.

Answer

The correct sequence begins with setting the gcloud project context, fetching the GKE cluster credentials into kubeconfig, validating cluster access with kubectl cluster-info, and finally deploying the application manifest with kubectl apply.
The deployment process requires setting the project context first so gcloud references the correct project. Next, generating local credentials populates kubeconfig, establishing a valid context for kubectl. Validating connection via cluster-info verifies the setup. Finally, applying the manifest submits the workload definition to the GKE control plane.

Step-by-Step Solution

1
Set the active GCP project
The CLI is configured to target the correct project.
Before executing cluster operations, gcloud must point to the project hosting the GKE cluster.
2
Run gcloud container clusters get-credentials
Local kubeconfig is populated with API endpoint and auth token/certificates.
kubectl requires local credentials and control plane address to interact with GKE.
3
Execute kubectl cluster-info
Control plane health and endpoint details are displayed.
Validating connection prevents deployment errors caused by targeting an incorrect or unreachable cluster.
4
Run kubectl apply -f deployment.yaml
Workload resources (Pods, Deployments, Services) are created on the cluster.
Deployment manifests can only be successfully submitted once authentication and cluster context are established.

Key Concept

Configuring local CLI tools (gcloud and kubectl) to access and manage GKE clusters
Estimated Time:1m 30s
Rate this question