
Answer-first summary for fast verification
Answer: gcloud container clusters create cluster-1 --zone=us-central1-a gcloud container clusters get-credentials cluster-1 --zone=us-central1-a kubectl apply -f deployment.yaml kubectl apply -f service.yaml
The correct sequence involves creating a GKE cluster with `gcloud container clusters create`, fetching its credentials with `gcloud container clusters get-credentials`, and then applying the Kubernetes resource configurations using `kubectl apply -f`. The other options either use incorrect commands (`kubectl create` or `gcloud gke apply`) or attempt to create a cluster with `kubectl`, which is not supported. References: - [Creating a GKE cluster](https://cloud.google.com/sdk/gcloud/reference/container/clusters/create) - [Fetching cluster credentials](https://cloud.google.com/sdk/gcloud/reference/container/clusters/get-credentials) - [Applying configurations with kubectl](https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#apply)
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
No comments yet.
You need to provision a GKE cluster in your development project and deploy Kubernetes resources defined in two YAML files: deployments.yaml for creating a deployment and service.yaml for setting up a LoadBalancer service. Which command sequence should you use in Cloud Shell to achieve this?
A
gcloud container clusters create cluster-1 --zone=us-central1-a gcloud container clusters get-credentials cluster-1 --zone=us-central1-a kubectl create -f deployment.yaml kubectl create -f service.yaml
B
gcloud container clusters create cluster-1 --zone=us-central1-a gcloud container clusters get-credentials cluster-1 --zone=us-central1-a kubectl apply -f deployment.yaml kubectl apply -f service.yaml
C
gcloud container clusters create cluster-1 --zone=us-central1-a gcloud container clusters get-credentials cluster-1 --zone=us-central1-a gcloud gke apply -f deployment.yaml gcloud gke apply -f service.yaml
D
kubectl container clusters create cluster-1 --zone=us-central1-a kubectl container clusters get-credentials cluster-1 --zone=us-central1-a kubectl apply -f deployment.yaml kubectl apply -f service.yaml