Courseiva
Application Design and BuildhardMultiple ChoiceObjective-mapped

CKAD Application Design and Build Practice Question

You have a multi-container pod with two containers: container-A and container-B. container-B needs to access the network of container-A. Which configuration is required?

⚠ Common exam trap

Many candidates think inter-container communication requires services or explicit port exposure, forgetting that containers in the same pod inherently share the network stack and can communicate via localhost.

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

No additional configuration is needed; they share the same network namespace

In Kubernetes, containers within the same pod share the same network namespace by default, including the same IP address and port space. This means container-B can reach container-A via localhost and the port that container-A is listening on, without any additional configuration. The shared network namespace is a fundamental property of pod design, enabling direct inter-container communication.

Answer analysis

Option-by-option breakdown

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

  • Define a ServiceAccount for container-B to access container-A

    Why it's wrong here

    A ServiceAccount in Kubernetes is an identity for Pods to authenticate to the Kubernetes API server (or other external systems via projected tokens). It has no role in enabling network communication between containers inside the same Pod. Container-B can already reach container-A through the shared pod network namespace via localhost, without any ServiceAccount. Creating one would be irrelevant and would not alter the network path.

  • No additional configuration is needed; they share the same network namespace

    Why this is correct

    Containers in a Pod share the same network namespace by design, meaning they all use the same IP address, loopback interface, and network stack. This allows container-B to simply connect to container-A's port using 127.0.0.1 or localhost. Kubernetes automatically configures this shared namespace, so no additional YAML settings, port mappings, or service definitions are required for inter-container communication.

  • Set hostNetwork: true in the pod spec

    Why it's wrong here

    Setting hostNetwork: true attaches the Pod directly to the node's network namespace, giving it the node's IP and full access to the host's network stack. This is only needed when a workload requires host-level network access (e.g., a daemon). For multi-container communication, it is unnecessary because the containers already share a network namespace within the Pod; using hostNetwork would also introduce potential port conflicts and reduce network isolation, which is generally undesirable.

  • Expose the port in container-A and map it in container-B

    Why it's wrong here

    Ports in a Pod are not 'exposed' or 'mapped' between containers the way they are for NodePort or LoadBalancer services. Within a Pod, every container listens on its own port on the same loopback interface, so container-B can directly access container-A's open port (e.g., http://localhost:8080) without any explicit mapping. The concept of exposing and mapping ports applies to making container ports available to external traffic, not to inter-container communication inside the same Pod.

About these practice questions

One of 160 original CKAD 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 CKAD 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 CKAD exam.