Courseiva
easyMultiple ChoiceObjective-mapped

Google ACE Practice Question: A developer has a Kubernetes Deployment manifest…

A developer has a Kubernetes Deployment manifest in a file named 'api-deployment.yaml'. Which command creates the Deployment if it doesn't exist, or updates it if it does?

⚠ Common exam trap

Google Cloud often tests the distinction between `create` (imperative, fails on existing resources) and `apply` (declarative, idempotent), trapping candidates who think `create` can also update or who confuse `run` with `apply`.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

kubectl apply -f api-deployment.yaml

`kubectl apply -f api-deployment.yaml` uses a declarative approach: it creates the Deployment if it does not exist, or performs a rolling update if it already exists, by applying the desired state defined in the YAML manifest. This command leverages the Kubernetes API's server-side apply logic, merging changes without requiring the resource to be deleted first.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • kubectl create -f api-deployment.yaml

    Why it's wrong here

    `kubectl create -f` sends an imperative 'create this object' request to the Kubernetes API server. If the Deployment already exists (a common situation when re-running a pipeline or updating a manifest), the API returns a Conflict error (HTTP 409) and the operation fails. Because `create` is not idempotent, it cannot safely manage the lifecycle of a resource across updates; it is only suitable for initial creation, not for regular deployments.

  • kubectl run api-deployment.yaml

    Why it's wrong here

    `kubectl run` is an imperative command that creates a Pod (or a Deployment in older versions) directly from an image name, not from a YAML manifest. It does not accept a filename as a positional argument in the way shown, and even if it did, it would ignore the `api-deployment.yaml` file entirely. This command is meant for quick one-off Pods or simple workloads, not for applying declarative resource definitions from files.

  • kubectl apply -f api-deployment.yaml

    Why this is correct

    `kubectl apply -f api-deployment.yaml` is the correct declarative approach: it reads the manifest, compares the desired state against the current cluster state, and creates or patches the resource as needed. This idempotent operation is safe to run repeatedly, making it the standard way to deploy and update resources in CI/CD pipelines and day-to-day kubectl workflows. It also records the last-applied configuration in the object's annotation for automatic conflict resolution.

  • kubectl deploy -f api-deployment.yaml

    Why it's wrong here

    The `kubectl deploy` subcommand does not exist in the kubectl CLI. Kubernetes manifests are applied declaratively via `kubectl apply` or imperatively via `kubectl create`/`run`; there is no `deploy` verb. Running this command would produce an error like 'unknown command' before any API interaction occurs, so it never reads the YAML file or contacts the cluster.

About these practice questions

One of 769 original ACE practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This ACE practice question is part of Courseiva's free Google Cloud certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the ACE exam.