Courseiva
Automation, Orchestration, and ScriptinghardMultiple ChoiceObjective-mapped

XK0-006 Automation, Orchestration, and Scripting Practice Question

A Kubernetes administrator needs to expose a deployment named 'web-app' running on port 80 internally within the cluster. Which kubectl command creates a service of type ClusterIP that maps port 80 to the target port 8080 on the pods?

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

kubectl expose deployment web-app --port=80 --target-port=8080

To create a ClusterIP service, use 'kubectl expose deployment web-app --port=80 --target-port=8080'. The --type=ClusterIP is default.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • kubectl create service nodeport web-app --tcp=80:8080

    Why it's wrong here

    This creates a NodePort, not ClusterIP, and uses incorrect syntax.

  • kubectl expose deployment web-app --port=80 --target-port=8080

    Why this is correct

    Correct. This creates a Service targeting port 80 and forwarding to container port 8080.

  • kubectl expose pod web-app --port=80 --target-port=8080

    Why it's wrong here

    Exposing a pod directly with `kubectl expose pod` creates a service that routes traffic to that single pod, not to the `web-app` deployment’s replica set. The stem requires exposing a *deployment*, which manages multiple pods and provides load balancing and self-healing; the correct command targets the deployment resource (`kubectl expose deployment web-app ...`). This option is tempting because `kubectl expose pod` works correctly when the goal is to expose a standalone pod that is not managed by a higher-level controller, such as during debugging or testing a single instance.

  • kubectl create service clusterip web-app --tcp=80:8080

    Why it's wrong here

    The syntax is incorrect; --tcp expects a different format.

About these practice questions

Courseiva writes every XK0-006 question from scratch — 979 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This XK0-006 practice question is part of Courseiva's free CompTIA certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the XK0-006 exam.