<p>I understand that a service of type ExternalName will point to a specified deployment that is not exposed externally using the specified external name as the DNS name. I am using minikube in my local machine with docker drive. I created a deployment using a custom image. When I created a service with default type (Cluster IP) and Load Balancer for the specific deployment I was able to access it after port forwarding to the local ip address. This was possible for service type ExternalName also but accessible using the ip address and not the specified <strong>external name</strong>.</p>
<p>According to my understanding service of type ExternalName should be accessed when using the specified <strong>external name</strong>. But I wasn't able to do it. Can anyone say how to access an external name service and whether my understanding is correct?</p>
<p>This is the <code>externalName.yaml</code> file I used.</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: k8s-hello-test
spec:
  selector:
    app: k8s-yaml-hello
  ports:
  - port: 3000
    targetPort: 3000
  type: ExternalName
  externalName: k8s-hello-test.com
</code></pre>
<p>After port forwarding using <code>kubectl port-forward service/k8s-hello-test 3000:3000</code> particular deployment was accessible using <code>http://127.0.0.1:300</code>
But even after adding it to <strong>etc/hosts</strong> file, cannot be accessed using <code>http://k8s-hello-test.com</code></p>

<blockquote>
<p>According to my understanding service of type ExternalName should be
accessed when using the specified external name. But I wasn't able to
do it. Can anyone say how to access it using its external name?</p>
</blockquote>
<p>You are wrong, external service is for making external connections. Suppose if you are using the third party Geolocation API like <a href="https://findmeip.com" rel="nofollow noreferrer">https://findmeip.com</a> you can leverage the <strong>External Name</strong> service.</p>
<blockquote>
<p>An ExternalName Service is a special case of Service that does not
have selectors and uses DNS names instead. For more information, see
the ExternalName section later in this document.</p>
</blockquote>
<p>For example</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: geolocation-service
spec:
  type: ExternalName
  externalName: api.findmeip.com
</code></pre>
<p>So your application can connect to <strong>geolocation-service</strong>, which which forwards requests to the external DNS mentioned in the service.</p>
<p>As <strong>ExternalName</strong> service does not have selectors you can not use the port-forwarding as it connects to POD and forwards the request.</p>
<p>Read more at : <a href="https://kubernetes.io/docs/concepts/services-networking/service/#externalname" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/services-networking/service/#externalname</a></p>
