An application running in a Kubernetes pod needs to access a database that is deployed on a VM outside the cluster. The database IP is stable. Which is the best way to expose the database to the pod?
Trap 1: Expose the database via Ingress
Ingress is for HTTP/HTTPS traffic, not TCP for databases.
Trap 2: Use a Headless Service
Headless services are for discovering pods, not external services.
Trap 3: Create an EndpointSlice manually with the pod IP
EndpointSlice is used for internal endpoints, not external IPs.
- A
Expose the database via Ingress
Why it fails: Ingress is for HTTP/HTTPS traffic, not TCP for databases.
- B
Create a Service of type ExternalName pointing to the database hostname
ExternalName service provides a DNS alias to an external resource.
- C
Use a Headless Service
Why it fails: Headless services are for discovering pods, not external services.
- D
Create an EndpointSlice manually with the pod IP
Why it fails: EndpointSlice is used for internal endpoints, not external IPs.