Bird
0
0

You want to manage a deployment over time, updating its image and replicas safely without deleting it. Which command should you use and why?

hard📝 Best Practice Q15 of 15
Kubernetes - kubectl Essential Commands
You want to manage a deployment over time, updating its image and replicas safely without deleting it. Which command should you use and why?
AUse <code>kubectl create deployment myapp --image=nginx</code> repeatedly to update the deployment.
BUse <code>kubectl apply -f deployment.yaml</code> because it creates or updates resources safely.
CUse <code>kubectl delete deployment myapp</code> then <code>kubectl create -f deployment.yaml</code> to update.
DUse <code>kubectl replace -f deployment.yaml</code> because it creates new resources.
Step-by-Step Solution
Solution:
  1. Step 1: Identify the need for safe updates over time

    Managing a deployment means updating it multiple times without deleting or failing.
  2. Step 2: Choose the command that supports create or update safely

    kubectl apply can create or update resources safely, preserving existing settings and avoiding errors.
  3. Step 3: Evaluate other options

    kubectl create fails if resource exists; deleting is disruptive; replace overwrites but is less safe than apply.
  4. Final Answer:

    Use kubectl apply -f deployment.yaml because it creates or updates resources safely. -> Option B
  5. Quick Check:

    Manage resources over time with apply [OK]
Quick Trick: Apply manages updates safely; create is one-time only [OK]
Common Mistakes:
  • Using create repeatedly causing errors
  • Deleting resources unnecessarily
  • Confusing replace with apply

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kubernetes Quizzes