Courseiva
Kubernetes Fundamentals →mediumMultiple Choice

KCNA Kubernetes Fundamentals Practice Question

A user runs 'kubectl create deployment my-deploy --image=nginx' and then wants to scale the deployment to 5 replicas. Which command should they use?

⚠ Common exam trap

The trap is that candidates may think `kubectl edit` or `kubectl patch` are the only ways to change replicas, but the KCNA exam expects knowledge of the dedicated imperative `kubectl scale` command for direct scaling operations.

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 scale deployment my-deploy --replicas=5

`kubectl scale` is the dedicated imperative command to change the replica count of a deployment. It directly updates the `spec.replicas` field in the deployment's desired state, and the deployment controller then adjusts the ReplicaSet and Pods accordingly. This is the simplest and most direct way to scale a deployment without modifying a YAML file or using an editor.

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 apply -f deployment.yaml with replicas: 5

    Why it's wrong here

    This works if you have a YAML file, but no file was provided.

  • ✗

    kubectl edit deployment my-deploy and change replicas to 5

    Why it's wrong here

    Editing the manifest works, but it opens an interactive editor rather than applying the change declaratively in one step, so it fails the scenario's expectation of a direct scaling command. It is tempting because `kubectl edit` genuinely modifies live object specs, and would be correct when changing fields that `kubectl scale` cannot touch, such as container images or resource limits.

  • ✗

    kubectl patch deployment my-deploy -p '{"spec":{"replicas":5}}'

    Why it's wrong here

    While `kubectl patch` can technically modify the `spec.replicas` field, it is not the idiomatic command for scaling a deployment. This command is designed for making direct, arbitrary modifications to a resource's specification via a JSON patch, not for the dedicated scaling operation. It is tempting because it directly alters the replica count, but the correct approach for scaling is to utilise `kubectl scale`, which specifically interacts with the deployment's scaling controller. `kubectl patch` would be appropriate for altering other, less common fields without a dedicated subcommand.

  • ✓

    kubectl scale deployment my-deploy --replicas=5

    Why this is correct

    `kubectl scale` adjusts the replica count on an existing Deployment's spec, letting the controller reconcile five Pods. It directly satisfies the stem's requirement to scale an already-created Deployment named my-deploy, without editing YAML or recreating the resource.

About these practice questions

Courseiva writes every KCNA question from scratch — 930 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. 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 KCNA practice question is part of Courseiva's free CNCF 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 KCNA exam.