In Kubernetes, we could use services to expose internal deployments as service-endpoints. But, how to map outside domain name into Kubernetes service to simply call the internal service before the external service?
Services of type ExternalName map a Service to a DNS name, not to a typical selector such as my-service or cassandra. You specify these Services with the spec.externalName parameter. This Service definition, for example, maps the my-service
Service in the prod namespace to my.database.example.com
:
apiVersion: v1
kind: Service
metadata:
name: my-service
namespace: prod
spec:
type: ExternalName
externalName: my.database.example.com
Note: ExternalName accepts an IPv4 address string, but as a DNS names comprised of digits, not as an IP address. ExternalNames that resemble IPv4 addresses are not resolved by CoreDNS or ingress-nginx because ExternalName is intended to specify a canonical DNS name. To hardcode an IP address, consider using headless Services.
https://cloud.google.com/blog/products/gcp/kubernetes-best-practices-mapping-external-services
You can expose an external name as a Kubernetes service so the pods within the cluster can access that internal service to talk to the outside name:
The doc is:
https://kubernetes.io/docs/concepts/services-networking/service/#externalname
Something like below will work:
apiVersion: v1
kind: Service
metadata:
name: my-service
spec:
type: ExternalName
externalName: my.database.example.com