<p>On Kubernetes, I can create a <code>Service</code>, and then an <code>Endpoint</code> which points to a set of external IP addresses, so I can have that <code>service</code> available inside the cluster. For example:</p>

<pre><code>kind: Service
apiVersion: v1
metadata:
  name: elasticsearch
spec:
  type: ClusterIP
  ports:
  - port: 9200
    targetPort: 9200

---

kind: Endpoints
apiVersion: v1
metadata:
  name: elasticsearch
subsets:
- addresses:
  - ip: 10.128.1.2
  - ip: 10.128.1.3
  - ip: 10.128.1.4
  - ip: 10.128.1.5
  ports:
  - port: 9200
</code></pre>

<p>This is nice, but it is a pain to keep it updated.</p>

<p>I thought maybe I could create a <code>Service</code> with an <code>ExternalName</code>, but I'm not sure if it round robin or just cache the <code>DNS</code> result and use it directly:</p>

<pre><code>kind: Service
apiVersion: v1
metadata:
  name: elasticsearch-dns
spec:
  type: ExternalName
  externalName: elasticsearch.foo.bar
</code></pre>

<p>Is there a way to create a service on Kubernetes, from an external DNS, which round robin the requests to the DNS multiple IP addresses?</p>

caarlos0
<p>When any application looks up the name <code>elasticsearch-dns</code>, the Cluster DNS returns a CNAME record with value <code>elasticsearch.foo.bar</code>. So there is no caching of IP or anything by kubernetes. </p>

<p><a href="https://kubernetes.io/docs/concepts/services-networking/service/#externalname" rel="nofollow noreferrer">From docs</a></p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: my-service
  namespace: prod
spec:
  type: ExternalName
  externalName: my.database.example.com
</code></pre>

<blockquote>
  <p>When looking up the host my-service.prod.svc.cluster.local, the
  cluster DNS Service returns a CNAME record with the value
  my.database.example.com. Accessing my-service works in the same way as
  other Services but with the crucial difference that redirection
  happens at the DNS level rather than via proxying or forwarding.</p>
</blockquote>
