KCNA · Question #85
Which of the following is the correct command to run a nginx deployment with 2 replicas? kubectl run deploy nginx --image=nginx --replicas=2 A.
The correct answer is B. kubectl create deploy nginx --image=nginx --replicas=2. The correct command to create a new Kubernetes Deployment with a specified image and number of replicas is kubectl create deployment.
Question
Options
- Bkubectl create deploy nginx --image=nginx --replicas=2
- Ckubectl create nginx deployment --image=nginx -replicas=2
How the community answered
(35 responses)- B91% (32)
- C9% (3)
Why each option
The correct command to create a new Kubernetes Deployment with a specified image and number of replicas is `kubectl create deployment`.
The `kubectl create deployment` command is specifically designed to create a Deployment resource, allowing parameters like `--image` to specify the container image and `--replicas` to define the desired number of pod instances. This creates a declarative object that Kubernetes will manage.
The syntax `kubectl create nginx deployment` is incorrect; the resource type `deployment` should follow `create`, and `-replicas` is not the standard flag (it should be `--replicas`).
Concept tested: Kubernetes Deployment creation via kubectl
Source: https://kubernetes.io/docs/reference/kubectl/cheatsheet/#creating-resources
Topics
Community Discussion
No community discussion yet for this question.