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`?
- Run gcloud container clusters get-credentials ecommerce-app --region us-east1 to generate the local kubeconfig context.Cevap
- Execute kubectl apply -f deployment.yaml to deploy the workload to the target GKE cluster.Cevap
- CRun gcloud config set container/cluster ecommerce-app to set the local Kubernetes context.
- DRe-create the GKE cluster using Autopilot mode because kubectl credentials cannot be generated for Standard clusters.
Cevap
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.
Adım Adım Çözüm
Anahtar Kavram
Fetching GKE cluster credentials using gcloud to configure local kubectl context