Soru

Zorluk: OrtaDeploying and Managing Google Kubernetes Engine (GKE) Clusters and Workloads

A lead developer at a logistics firm needs to administer workloads on a newly deployed Google Kubernetes Engine (GKE) Autopilot cluster named `logistics-tracking-prod` in the `europe-west1` region. Although the developer has authenticated to Google Cloud via `gcloud auth login`, running `kubectl get pods` fails with an error indicating that the connection to `localhost:8080` was refused. Which `gcloud` command must the developer execute to update local cluster credentials and enable `kubectl` management?

  1. gcloud container clusters get-credentials logistics-tracking-prod --region europe-west1Cevap
  2. B
    gcloud config set container/cluster logistics-tracking-prod
  3. C
    gcloud container node-pools create default-pool --cluster logistics-tracking-prod --region europe-west1
  4. D
    gcloud container clusters create logistics-tracking-prod --spot --region europe-west1

Cevap

Execute `gcloud container clusters get-credentials logistics-tracking-prod --region europe-west1` to write cluster credentials and endpoint details into the local `kubeconfig` file.
Running the command `gcloud container clusters get-credentials logistics-tracking-prod --region europe-west1` fetches the endpoint details and security credentials for the GKE cluster and writes them into the local user's `kubeconfig` file, allowing `kubectl` commands to correctly locate and authenticate with the remote control plane.

Adım Adım Çözüm

1
Identify the cause of the `localhost:8080` connection failure
The `kubectl` CLI utility defaults to `localhost:8080` when no valid cluster context is configured in `~/.kube/config`.
Authenticating with `gcloud auth login` establishes GCP user credentials but does not automatically populate Kubernetes cluster endpoints in `kubeconfig`.
2
Fetch the GKE cluster credentials using the `gcloud container` component
Running `gcloud container clusters get-credentials logistics-tracking-prod --region europe-west1` retrieves cluster keys and API endpoint information.
This populates the local `kubeconfig` entry and updates the active `kubectl` context to target the GKE cluster in `europe-west1`.
3
Verify cluster connectivity
`kubectl get pods` successfully sends requests to the GKE control plane API server.
The local client now contains valid tokens and the server URL needed for Kubernetes API communication.

Anahtar Kavram

Configuring local kubectl context for GKE clusters using gcloud get-credentials
Tahmini Süre:1m 30s
Bu soruyu puanla