Bird
0
0

Given the commands below, what will happen if the deployment myapp already exists?

medium📝 Command Output Q13 of 15
Kubernetes - kubectl Essential Commands
Given the commands below, what will happen if the deployment myapp already exists?

kubectl create deployment myapp --image=nginx
kubectl apply -f deployment.yaml
ABoth commands will fail because the deployment exists.
BBoth commands will update the deployment.
CThe create command will update; the apply command will fail.
DThe create command will fail; the apply command will update the deployment.
Step-by-Step Solution
Solution:
  1. Step 1: Behavior of kubectl create on existing resource

    kubectl create fails if the resource already exists, so the first command will fail.
  2. Step 2: Behavior of kubectl apply on existing resource

    kubectl apply updates the existing resource safely, so the second command updates the deployment.
  3. Final Answer:

    The create command will fail; the apply command will update the deployment. -> Option D
  4. Quick Check:

    create fails if exists; apply updates [OK]
Quick Trick: Create fails if exists; apply updates existing resources [OK]
Common Mistakes:
  • Assuming create updates existing resources
  • Thinking apply fails if resource exists
  • Believing both commands behave the same

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kubernetes Quizzes