You want to create an ExternalName service named db-access that points to db.external.com and allows pods to connect on port 3306. How should you configure this service?
hard📝 Application Q8 of 15
Kubernetes - Services
You want to create an ExternalName service named db-access that points to db.external.com and allows pods to connect on port 3306. How should you configure this service?
ACreate a NodePort service exposing port 3306 and set <code>externalName: db.external.com</code>.
BCreate an ExternalName service with <code>type: ExternalName</code>, <code>externalName: db.external.com</code>, and define port 3306 under <code>ports</code>.
CCreate a ClusterIP service with selector and port 3306 pointing to pods running the database.
DCreate an ExternalName service with <code>type: ExternalName</code> and <code>externalName: db.external.com</code> without specifying ports.
Step-by-Step Solution
Solution:
Step 1: Understand ExternalName limitations
ExternalName services only map a service name to an external DNS name and do not support port definitions.
Step 2: Analyze options
Create an ExternalName service with type: ExternalName and externalName: db.external.com without specifying ports. correctly creates an ExternalName service without ports. Create an ExternalName service with type: ExternalName, externalName: db.external.com, and define port 3306 under ports. is invalid because ports are ignored in ExternalName services. Options C and D describe other service types not suitable for ExternalName.
Final Answer:
Create an ExternalName service with type: ExternalName and externalName: db.external.com without specifying ports. -> Option D
Quick Check:
ExternalName ignores ports, only DNS mapping [OK]
Quick Trick:ExternalName ignores ports, only DNS mapping [OK]
Common Mistakes:
Adding ports to ExternalName services expecting them to work
Confusing ExternalName with ClusterIP or NodePort services
Master "Services" in Kubernetes
9 interactive learning modes - each teaches the same concept differently