ExternalName maps an internal service name to an external domain name within a cluster, allowing Pods in the cluster to access the external domain name using the Service name. This topic describes how to configure a service of the ExternalName type.
When you create a Service of the ExternalName type in a cluster, Kubernetes does not assign a ClusterIP to the Service or create Endpoints. Instead, Kubernetes uses CoreDNS to return a CNAME record that maps the service name to an external DNS domain name. Workloads inside the cluster can access external services using the Service name (for example, service-demo.default.svc.cluster.local), without hardcoding the external domain name in the application.
tip
Before configuring an ExternalName Service using the kubectl command-line interface, ensure that the following conditions are met:
- Create a YAML file for the service. The following external-service-demo.yaml file serves as an example:
- Run the following command to create a Service.
The service you created can be found in the service list.
Testing the connections to services
After the Service is created, you can access the external domain name using the Service name. You can run the following command inside the Pod to validate domain name resolution and connectivity.
The expected resolution results include a CNAME record for volcengine.com, as well as the resolved real IP address, indicating that the ExternalName mapping has taken effect.