Kubernetes and Cloud Native Associate (KCNA) — Question 70
Which of the following is the correct command to run a nginx deployment with 2 replicas?
Answer options
- A. kubectl run deploy nginx --image=nginx --replicas=2
- B. kubectl create deploy nginx --image=nginx --replicas=2
- C. kubectl create nginx deployment --image=nginx –replicas=2
- D. kubectl create deploy nginx --image=nginx --count=2
Correct answer: B
Explanation
The correct answer is B because the 'kubectl create deploy' command is the correct way to create a deployment in Kubernetes, and it supports specifying the number of replicas with the '--replicas' flag. Option A is incorrect as 'kubectl run' does not support creating deployments with replicas directly. Options C and D are incorrect due to incorrect command syntax or flags.