
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,service.yaml]`, `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&&service.yaml`
The correct commands for creating a GKE cluster and deploying YAML configuration files involve creating the cluster with `gcloud container clusters create`, fetching credentials with `gcloud container clusters get-credentials`, and applying the configurations with `kubectl apply -f`. The commands in options A and B fail because they incorrectly format the file names for `kubectl apply`. Option A uses a list format `[deployment.yaml,service.yaml]` which Kubernetes treats as literal filenames, and option B uses `&&` as a separator, which is also treated as part of the filename. The other options correctly apply the configurations either by specifying files separately or using a comma as a separator.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
No comments yet.
You have two Kubernetes resource configuration files: deployments.yaml for creating a deployment and service.yaml for setting up a LoadBalancer service to expose the pods. You need to provision a GKE cluster in your development project where none exists. Which of the following commands will fail with an error in Cloud Shell when attempting to create a GKE cluster and deploy the YAML configuration files? (Select Two)
A
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,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&&service.yaml
C
gcloud config set compute/zone us-central1-a gcloud container clusters create cluster-1 gcloud container clusters get-credentials cluster-1 --zone=us-central1-a kubectl apply -f deployment.yaml kubectl apply -f service.yaml
D
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
E
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,service.yaml