To be able to access an application that lives outside of a kubernetes cluster, we use a service called externalName.
The externalName gives us more flexibility, since we access the external application through it and not directly.
If the external application gets moved for example to another location, all we have to do, is modify our externalName service parameter "externalName". We don't need to change the application accessing the external application.
Below an example of an externalName:
We have for example an application running outside of the kubernetes cluster with the address "database.external.com".
Below is the Yaml file of our external service:
We can even specify the namespace from which the external application would be accessible, as can see in the above file.
ExternalName is not an entry point to pods, so selectors are not needed.
We just need to populate the Yaml file with the URL of our external application - database.external.com - The DNS will take care of mapping the external name to an IP address.