A namespace in Kubernetes is like a separate room in a big house. It helps organize and isolate resources like pods and services so they don't mix with others.
Click to reveal answer
beginner
How can pods in one namespace communicate with pods in another namespace?
Pods can talk across namespaces by using the full service name, which includes the service name and the namespace, like service-name.namespace.svc.cluster.local.
Click to reveal answer
beginner
What is the default DNS format to access a service in another namespace?
The format is <service-name>.<namespace>.svc.cluster.local. This tells Kubernetes exactly where to find the service.
Click to reveal answer
intermediate
Why might you want to restrict cross-namespace communication?
To keep things safe and organized, you might limit communication so only certain namespaces can talk to each other. This helps prevent mistakes or security problems.
Click to reveal answer
intermediate
How can Network Policies help with cross-namespace communication?
Network Policies can control which pods in one namespace can connect to pods in another. They act like traffic rules to allow or block communication.
Click to reveal answer
What is the correct DNS name format to access a service named 'web' in namespace 'frontend'?
Aweb.frontend.svc.cluster.local
Bfrontend.web.svc.cluster.local
Cweb.svc.frontend.cluster.local
Dfrontend.web.cluster.local
✗ Incorrect
The correct format is service-name.namespace.svc.cluster.local, so 'web.frontend.svc.cluster.local' is correct.
By default, can pods in different namespaces communicate without extra configuration?
AYes, they can communicate using service DNS names
BNo, communication is blocked by default
COnly if they are in the same node
DOnly if Network Policies allow it
✗ Incorrect
By default, Kubernetes allows cross-namespace communication using service DNS names unless Network Policies restrict it.
What Kubernetes feature can restrict cross-namespace pod communication?
AConfigMaps
BNamespaces
CNetwork Policies
DPersistent Volumes
✗ Incorrect
Network Policies define rules to allow or block traffic between pods, including across namespaces.
If a pod in namespace 'A' wants to call a service in namespace 'B', what must it use?
AOnly the service name
BThe full service DNS name including namespace
CThe pod IP address
DThe node IP address
✗ Incorrect
Using the full DNS name with the namespace ensures the pod finds the correct service in another namespace.
What is a simple way to test cross-namespace communication?
ACreate a ConfigMap
BRestart the Kubernetes cluster
CDelete the namespace
DUse a pod in one namespace to ping a service in another namespace
✗ Incorrect
Testing with a ping or curl command from a pod in one namespace to a service in another shows if communication works.
Explain how pods in different Kubernetes namespaces can communicate with each other.
Think about how Kubernetes DNS helps find services across namespaces.
You got /3 concepts.
Describe how Network Policies can control cross-namespace communication and why this might be important.
Consider how you keep different teams or apps separated safely.
You got /3 concepts.
Practice
(1/5)
1. What is the main purpose of namespaces in Kubernetes?
easy
A. To group and isolate resources within the cluster
B. To increase the number of nodes in the cluster
C. To speed up container startup time
D. To automatically update container images
Solution
Step 1: Understand namespaces role
Namespaces help organize and isolate resources like pods and services inside a Kubernetes cluster.
Step 2: Compare options
Options B, C, and D describe unrelated cluster features, not namespaces.
Final Answer:
To group and isolate resources within the cluster -> Option A
Quick Check:
Namespaces = resource grouping and isolation [OK]
Hint: Namespaces isolate resources logically inside the cluster [OK]
Common Mistakes:
Confusing namespaces with nodes
Thinking namespaces speed up containers
Assuming namespaces auto-update images
2. Which DNS name format is correct to access a service named webapp in namespace prod from another namespace?
easy
A. svc.webapp.prod.cluster.local
B. prod.webapp.svc.cluster.local
C. webapp.prod.svc.cluster.local
D. webapp.svc.prod.cluster.local
Solution
Step 1: Recall Kubernetes DNS format
The full DNS name for a service is service.namespace.svc.cluster.local.
Step 2: Match the format to the service and namespace
For service webapp in namespace prod, the correct format is webapp.prod.svc.cluster.local.
Final Answer:
webapp.prod.svc.cluster.local -> Option C
Quick Check:
DNS = service.namespace.svc.cluster.local [OK]
Hint: Use service.namespace.svc.cluster.local for cross-namespace access [OK]
Common Mistakes:
Swapping service and namespace order
Omitting 'svc' in DNS name
Using incorrect domain suffix
3. Given this command run in namespace dev:
kubectl exec -n dev pod1 -- curl http://api.prod.svc.cluster.local
What is the expected result if api service exists in prod namespace and network policies allow cross-namespace traffic?
medium
A. The curl command fails with DNS resolution error
B. The pod1 container crashes immediately
C. The curl command times out due to network policy blocking
D. The curl command successfully connects to the api service
Solution
Step 1: Understand DNS and network policy
The DNS name api.prod.svc.cluster.local correctly targets the service in the prod namespace.
Step 2: Check network policy effect
Since network policies allow cross-namespace traffic, the connection is permitted.
Final Answer:
The curl command successfully connects to the api service -> Option D
Quick Check:
Allowed network + correct DNS = successful connection [OK]
4. You try to access db.prod.svc.cluster.local from namespace dev but get a timeout. What is the most likely cause?
medium
A. The service db does not exist in prod
B. Network policies block traffic between dev and prod
C. The pod in dev has no internet access
D. The DNS name is incorrectly formatted
Solution
Step 1: Verify service existence
If the service did not exist, DNS would fail, not timeout.
Step 2: Analyze network policy impact
Timeout usually means packets are blocked by network policies preventing cross-namespace communication.
Final Answer:
Network policies block traffic between dev and prod -> Option B
Quick Check:
Timeout = network block, not DNS error [OK]
Hint: Timeout often means network policy blocks traffic [OK]
Common Mistakes:
Confusing timeout with DNS failure
Assuming pod internet access affects cluster DNS
Misreading DNS format as cause
5. You want to allow a pod in namespace frontend to access a service backend in namespace api. Which steps are needed to enable this cross-namespace communication?
hard
A. Use the full DNS name backend.api.svc.cluster.local and configure network policies to allow traffic from frontend to api
B. Create a service account in frontend and bind it to api namespace
C. Expose the backend service as NodePort and access it via node IP
D. Deploy the backend service in frontend namespace instead
Solution
Step 1: Use correct DNS name for cross-namespace access
Accessing a service in another namespace requires the full DNS name: backend.api.svc.cluster.local.
Step 2: Configure network policies
Network policies must allow traffic from pods in frontend namespace to api namespace services.
Final Answer:
Use the full DNS name backend.api.svc.cluster.local and configure network policies to allow traffic from frontend to api -> Option A
Quick Check:
DNS + network policy = cross-namespace communication [OK]
Hint: Full DNS + network policy allow = cross-namespace access [OK]
Common Mistakes:
Confusing service accounts with network access
Using NodePort unnecessarily
Moving services instead of configuring access
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.