Container Orchestration
medium
Pregunta de Container Orchestration #019e3a4f
Enunciado de la Pregunta
Container Orchestration
#kubernetes
#kubectl
#deployment
#replicas
Medio
Which of the following is the correct command to run a nginx deployment with 2 replicas?
A
kubectl run deploy nginx --image=nginx --replicas=2
B
kubectl create deploy nginx --image=nginx --replicas=2
Correcto
C
kubectl create nginx deployment --image=nginx –replicas=2
D
kubectl create deploy nginx --image=nginx --count=2
Explicación Oficial / Explicaciones de la Comunidad
The correct command to create a Kubernetes Deployment with 2 replicas is kubectl create deploy nginx --image=nginx --replicas=2. This uses the kubectl create deployment subcommand (abbreviated as deploy) to create a Deployment named nginx with the specified container image and replica count.
How it Works
kubectl create deploymentis the standard command to create a Deployment resource in Kubernetes.- The
--imageflag specifies the container image to use for the pods. - The
--replicasflag sets the desired number of pod replicas. - The Deployment controller ensures that the specified number of pods are running and handles updates and rollbacks.
Why Other Options Are Incorrect
kubectl run deploy nginx --image=nginx --replicas=2: Thekubectl runcommand is used to create a single pod or a deployment, but its syntax for creating a deployment iskubectl run <name> --image=<image>. The--replicasflag is not valid forkubectl run; it only creates a single pod by default. Additionally, the worddeployin the command is misinterpreted as the pod name, not a subcommand.kubectl create nginx deployment --image=nginx –replicas=2: This command has incorrect argument order. The correct syntax iskubectl create deployment <name> --image=<image>. Placing the name aftercreateand beforedeploymentis invalid.kubectl create deploy nginx --image=nginx --count=2: The--countflag is not a valid flag forkubectl create deployment. The correct flag is--replicas. Using--countwill result in an error or be ignored.