While Kubernetes Components constitutes the essential parts of the Kubernetes platform, there are also add-ons, which extend the core functionalities. They are optional, but some are highly recommended and are often included by default. In fact, the Web UI Dashboard is an example of an add-on.
Another such add-on is kube-dns, a DNS server which is used by Pods to resolve hostnames.
This DNS server watches the Kubernetes API for new Services. When a new Service is created, a DNS record is created that would route the name <service-name>.<service-namespace> to the Service's Cluster IP. Or, in the case of a Headless Service (without a cluster IP), a list of IPs of the Pods that constitutes the Headless Service.
This is why we can use "http://elasticsearch" as the value of the ELASTICSEARCH_HOSTNAME environment variable, because the DNS server will resolve it, even if the Service changes its IP.