A cloud administrator receives a newly provisioned workstation and installs `kubectl` to manage an existing regional Google Kubernetes Engine (GKE) cluster named `ecommerce-prod` located in the `us-east4` region. When running `kubectl get pods`, the command fails with an error stating `The connection to the server localhost:8080 was refused`. Which `gcloud` command must the administrator execute to populate the local kubeconfig file with cluster context credentials?
- gcloud container clusters get-credentials ecommerce-prod --region us-east4Answer
- Bgcloud config set container/cluster ecommerce-prod
- Cgcloud container clusters update ecommerce-prod --enable-autopilot --region us-east4
- Dgcloud container node-pools create spot-pool --cluster=ecommerce-prod --spot --region us-east4
Answer
Execute `gcloud container clusters get-credentials ecommerce-prod --region us-east4` to generate the necessary cluster endpoint entries and authentication tokens in the local kubeconfig file.
Running `gcloud container clusters get-credentials` fetches the control plane certificates and generates an entry in the local `~/.kube/config` file. This configures `kubectl` with the correct cluster API server address and credentials required to perform operations against the target GKE cluster.
Step-by-Step Solution
Key Concept
GKE Kubeconfig Authentication & Context Provisioning
Estimated Time:1m 30s