Question 23
Domain 2: Application Deployment and WorkloadsWhich command/configuration best creates a Deployment named nginx using image nginx:1.18.0, with 2 replicas and container port 80 exposed, without creating a Service?
Correct answer: A
Explanation
A Deployment is the Kubernetes object used to manage replicated Pods, so setting "2 replicas" and the image "nginx:1.18.0" matches the requested workload. Exposing "containerPort 80" defines the port inside the container, and since the prompt says "without creating a Service," only the Deployment should be created.
Why each option is right or wrong
A. Create a Deployment named nginx with 2 replicas, container image nginx:1.18.0, and containerPort 80; do not create any Service.
Under the Kubernetes API, a Deployment in `apps/v1` is the correct object for managing replicated Pods, and the `spec.replicas` field is what sets the desired count to 2. The container spec must include `image: nginx:1.18.0` and `ports: [{containerPort: 80}]`; `containerPort` only declares the port inside the Pod and does not create any network Service object. Since the question explicitly excludes a Service, any command that also generates a Service would be over-inclusive and therefore incorrect.
B. Create a StatefulSet named nginx with 2 replicas, image nginx:1.18.0, and expose port 80 via a Service.
C. Create a Deployment named nginx with 1 replica, image nginx:latest, and expose port 8080.
D. Create a Pod named nginx using image nginx:1.18.0 with port 80 exposed.