Bird
0
0

Which kubectl command correctly updates the image of a deployment named webapp to nginx:1.21 without downtime?

hard📝 Workflow Q8 of 15
Kubernetes - kubectl Essential Commands
Which kubectl command correctly updates the image of a deployment named webapp to nginx:1.21 without downtime?
Akubectl edit deployment webapp and change the image manually
Bkubectl set image deployment/webapp webapp=nginx:1.21
Ckubectl replace -f updated-deployment.yaml
Dkubectl rollout restart deployment/webapp
Step-by-Step Solution
Solution:
  1. Step 1: Understand zero-downtime update

    The kubectl set image command updates the image and triggers a rolling update.
  2. Step 2: Evaluate options

    kubectl set image deployment/webapp webapp=nginx:1.21 uses the correct syntax for updating the image directly. kubectl edit deployment webapp and change the image manually is manual and error-prone. kubectl replace -f updated-deployment.yaml replaces the entire deployment which may cause downtime. kubectl rollout restart deployment/webapp restarts pods but does not update the image.
  3. Final Answer:

    kubectl set image deployment/webapp webapp=nginx:1.21 -> Option B
  4. Quick Check:

    Does the command update the image and trigger a rolling update? [OK]
Quick Trick: Use 'kubectl set image' for seamless image updates [OK]
Common Mistakes:
  • Using rollout restart without changing image
  • Manually editing deployment risking errors
  • Replacing deployment causing downtime

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kubernetes Quizzes