Courseiva
Services and Networking →mediumMultiple Choice

CKA Services and Networking Practice Question

A developer runs `kubectl run nginx --image=nginx --port=80` and then `kubectl expose pod nginx --port=80 --target-port=80 --type=NodePort`. What is the name of the created Service?

⚠ Common exam trap

A common mix-up: candidates assume `kubectl expose` appends a suffix like '-service' or uses a different naming pattern, but the default behavior is to reuse the exact resource name without any modification.

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

✓

nginx

The `kubectl expose pod nginx --port=80 --target-port=80 --type=NodePort` command creates a Service that inherits its name from the resource being exposed, which is the pod named 'nginx'. By default, `kubectl expose` uses the name of the referenced resource (in this case, the pod) as the Service name, resulting in a Service named 'nginx'. This is consistent with Kubernetes behavior where the Service name is derived from the resource name unless overridden with the `--name` flag.

Answer analysis

Option-by-option breakdown

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

  • ✓

    nginx

    Why this is correct

    When you expose a Kubernetes resource such as a Pod using the kubectl expose command, the resulting Service inherits the exact name of the target resource by default. Since the Pod created in this command is named nginx, the generated Service will also be named nginx unless an explicit --name override is provided.

  • ✗

    expose-nginx

    Why it's wrong here

    Kubernetes does not prepend action verbs like "expose" to generated resource names during creation. The command-line tool strictly derives the default Service name from the metadata of the target workload itself. Prefixing the action to the resource name is not a standard convention in any kubectl generators.

  • ✗

    nginx-service

    Why it's wrong here

    While appending "-service" to a resource name is a common manual naming convention used by administrators to distinguish Services from Pods, kubectl does not automatically apply this suffix. To achieve this specific name, you would need to explicitly pass the --name=nginx-service flag during the execution of the expose command.

  • ✗

    nginx-pod

    Why it's wrong here

    This option incorrectly assumes that the Service name is derived by appending the resource type to the Pod's name. Kubernetes avoids adding suffix descriptors like "-pod" to the generated Service name, as the Service is a distinct API object whose type is already defined in its metadata.

About these practice questions

One of 726 original CKA practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. 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 CKA practice question is part of Courseiva's free CNCF 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 CKA exam.