Deploying a Kubernetes App on a New GKE Cluster

PCA By islever Editorial Last updated

Configuring compute systems. Interacting with Google Cloud programmatically.

Short answer

B Create the GKE cluster with gcloud container clusters create, then apply the Deployment file with kubectl apply -f.

Question

The development team has provided you with a Kubernetes Deployment file. You have no infrastructure yet and need to deploy the application. What should you
do?
  1. Use gcloud to create a Kubernetes cluster. Use Deployment Manager to create the deployment.
  2. Use gcloud to create a Kubernetes cluster. Use kubectl to create the deployment. Correct Answer
  3. Use kubectl to create a Kubernetes cluster. Use Deployment Manager to create the deployment.
  4. Use kubectl to create a Kubernetes cluster. Use kubectl to create the deployment.

Key Takeaways

The test measures whether you know which tool provisions GKE infrastructure versus which tool drives an existing cluster; the trap is assuming Deployment Manager can apply a Kubernetes Deployment YAML, which it cannot.

When no infrastructure exists and a Kubernetes Deployment file is provided, the cluster must be provisioned first with the Google Cloud CLI (gcloud container clusters create) and the workload applied afterwards with kubectl. This question tests the correct division of labor between gcloud (GKE infrastructure provisioning) and kubectl (cluster workload management), and confirms that answer B is the standard workflow.

Common mistake: Option A is the most tempting wrong answer: learners reason that because we have a Deployment file, Deployment Manager should handle it. Deployment Manager provisions Google Cloud infrastructure templates, not Kubernetes resources inside a cluster — applying a Deployment manifest requires kubectl (or the GKE API via kubectl-compatible tooling).

Expert Analysis

Why the Answer Is Correct

Option B matches the canonical GKE workflow. Because there is no infrastructure yet, the cluster must be created first, and the supported CLI for that is gcloud container clusters create <name> --zone <zone>, which provisions a managed control plane and node pools. Once the cluster exists and credentials are fetched, kubectl apply -f deployment.yaml (or kubectl create -f) submits the development team's Deployment manifest to the Kubernetes API server, exactly the mechanism the file was written for. Community members spell this out with real commands, e.g. "gcloud container clusters create my-cluster --zone us-central1-a" followed by "kubectl apply -f file.yml". This two-tool split is the officially documented deployment path for GKE.

Why the Other Options Are Wrong

Option C and D are invalid because kubectl cannot create a GKE cluster: kubectl is a Kubernetes API client and only works once a cluster and an API endpoint already exist, so "Use kubectl to create a Kubernetes cluster" is impossible in this scenario. Option A uses the correct cluster-creation step but then points to Deployment Manager for the application deployment; Deployment Manager provisions Google Cloud resources from configuration templates (VMs, disks, networks), it does not apply Kubernetes workload manifests to a cluster. As one commenter noted, "Deployment Manager is used to automate the process of provisioning infrastructure," which overlaps with gcloud and still leaves kubectl as the only correct tool for the Deployment file. There is no option that mixes both tools correctly other than B.

Community Comment Notes

The community is overwhelmingly and correctly aligned on B, with MeasService stating plainly "It has to be B. gcloud for creating cluster and kubectl for deploying." KouShikyou's question "May I ask why C is correct? I thought B was correct" reflects confusion worth addressing: C is wrong because kubectl cannot provision a GKE cluster. lynx256 asks why Deployment Manager cannot be used instead of kubectl in option A, and ghadxx's reply resolves it — Deployment Manager automates provisioning of infrastructure, not in-cluster Kubernetes objects. Multiple commenters supply working command sequences (gadxx's two-step, GtanNar's create/run/expose pipeline) that independently confirm B.

Official Reference

Exam Strategy

When a question gives you no existing infrastructure, always look for the option that provisions the managed service with gcloud first, then performs the Kubernetes-specific action with kubectl. Eliminate any option where kubectl is asked to create a cluster — it is a client tool, not a provisioner.

Frequently Asked Questions

Why can't Deployment Manager apply the Kubernetes Deployment file (option A)?

Deployment Manager provisions Google Cloud infrastructure from templates (VMs, networks, disks); it does not create Kubernetes workload objects. A Deployment manifest must be submitted through kubectl against a running cluster's API server.

Why is 'Use kubectl to create a Kubernetes cluster' wrong in options C and D?

kubectl is a client for an existing Kubernetes API endpoint, so it cannot provision a GKE cluster. Creating a cluster on Google Cloud is done with gcloud container clusters create, the Console, or Terraform.

More PCA FAQ →

Discussion 71 contributions

Compiled from public community threads and reader submissions, lightly edited for clarity. Handles and vote tallies are shown as recorded, and comments reflect the views of individual contributors.

From public community threads 30 of 71

  1. MeasService 👍 54
    It has to be B. gcloud for creating cluster and kubectl for creating deployment
  2. KouShikyou 👍 26
    May I ask why C is correct? I thought B was correct.
  3. GtanNar 👍 9
    B is right: 1 - Create cluster with glcoud console 2 - Use kubectl for the deploy Check this: gcloud container clusters create webfrontend --zone us-central1-a --num-nodes 2 kubectl run nginx --image=nginx:1.10.0 kubectl expose deployment nginx --port 80 --type LoadBalancer
  4. ghadxx 👍 9 Answered B
    Deployment Manager is used to automate the process of provisioning infrastructure. Therefore, gcloud and Deployment Manager do the same thing. Meanwhile, kubectl is used to run commands against an already created cluster.
  5. passnow 👍 6
    I would go with B even in my sleep. . Use gcloud to create a Kubernetes cluster. Use kubectl to create the deployment.
Show 25 more comments
  1. pentium2000 👍 5
    B Step 1: gcloud container clusters create my-cluster --zone us-central1-a Step 2: kubectl apply -f file.yml
  2. vamgcp 👍 4
    Create a Google Kubernetes Engine (GKE) cluster: You can use the Google Cloud Console or the gcloud command-line tool to create a GKE cluster, which will provide the underlying infrastructure for running your application. Deploy the application to the cluster: You can use the kubectl command-line tool to apply the Kubernetes Deployment file provided by the development team to the cluster.kubectl apply -f deployment.yaml
  3. lynx256 👍 4
    Why we cannot use Deployment Manager (instead of kubectl) to create the deployment (opt. A)? We have the Deployment file, so why we cannot use it with Deployment Manager ?
  4. res3 👍 4
    yeap, gcloud command to create K8s cluster https://cloud.google.com/kubernetes-engine/docs/how-to/creating-a-cluster
  5. kumarp6 👍 4
    B is correct, when you create a nodes in GKE you use gcloud rather than kubectl...
  6. shark 👍 4
    i think B
  7. ale183 👍 3
    Question for all , do we know if only new questions are part of the bank for new exam? Have any of the old questions appeared on new exam?
  8. Raja101 👍 3
    Why not A ?
  9. akhilesh_pundir 👍 2
    No the correct answer is B. Gcloud is used to create kubernetes cluster. https://cloud.google.com/sdk/gcloud/reference/container/clusters/create Sample for deployment creation: kubectl create deployment kubernetes-bootcamp --image=gcr.io/google-samples/kubernetes-bootcamp:v1
  10. wiqi 👍 2
    B is correct. Since you have Kubernetes deployment file. You need to deploy the cluster using: gcloud container clusters create gke-cluster-1 --num-nodes=2 Once the cluster is up. You simply apply the deployment file using: kubectl apply -f <deployment-file.yaml>
  11. MaxNRG 👍 2
    B – use gcloud to create cluster, use kubectl to create a deployment. https://cloud.google.com/kubernetes-engine/docs/how-to/creating-a-zonal-cluster In fact, kubectl run creates a deployment. https://cloud.google.com/kubernetes-engine/docs/tutorials/hello-app
  12. haroldbenites 👍 2
    Go for B. gcloud for create clusters. kubectl is used when the cluster already has been created. For example to create deployments. Kubectl has configured a config file where is specified the default cluster.
  13. Eroc 👍 2
    Further documentation on gcloud for cluster creation (https://cloud.google.com/kubernetes-engine/docs/how-to/creating-a-cluster)
  14. getAlok 👍 2
    B Create kubernaes cluster - gcloud container clusters create my-cluster --zone Do deployment - kubectl apply -f file name
  15. SAMBIT 👍 2
    Kubctle comes live only when cluster has been created in the cloud console using cloud command
  16. hyz1991 👍 2
    I just curious who put an "official" solution over here? It has zero correct guarantee
  17. victory108 👍 2
    B. Use gcloud to create a Kubernetes cluster. Use kubectl to create the deployment.
  18. nitinz 👍 2
    B, gcloud to manage GKE and to manage pods use kubctl.
  19. Khalnaik 👍 2
    Definitely B
  20. varushar 👍 1
    Essentially, gcloud gives you the ability to provision and deprovision resources, whereas kubectl gives you the ability to use the clusters once provisioned. Answer must be B, IMO
  21. Googler2 👍 1
    Answer B - Why this website is suggesting answer like A ? we know container clusters can only be created with gcloud. kubectl is for deployments.
  22. aviratna 👍 1
    B is correct. 1st create GKE cluster using gcloud command and then use kubectl command for application deployment using deployment
  23. AdityaGupta 👍 1
    Correct Answer is B, gcloud is used to create kubernets cluster and kubectl commnds are used to create container deployments.
  24. ahmedemad3 👍 1
    Ans: B gcloud create the Ku8 clusters and kubectl for deployment https://cloud.google.com/kubernetes-engine/docs/quickstart
  25. Zinhle 👍 1
    Hi all may someone please share the link for the bank of questions because I cannot seem to locate them. thank you

Reader comments & corrections

No reader corrections yet — spotted an error or have a note? Share it below.

Log in to comment, report an error, or add a note about this question.

Practice All PCA Questions

Access 81 questions with complete answers and detailed explanations.

View Full PCA Practice Test →

← Back to PCA Study Guide