<p>Is there a way for a Kubernetes ClusterIP Service to have a network alias, other than its <code>metadata.name</code> field value?</p>
<p>Docker-compose has a similar functionality with <a href="https://docs.docker.com/compose/compose-file/compose-file-v3/#aliases" rel="nofollow noreferrer">network aliases</a>.</p>

xenosdio
<p>If I good understand your question you can also configure HostAliases for a Pod under <code>.spec.hostAliases</code> using <code>/etc/hosts</code> file. Look at the example:</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
kind: Pod
metadata:
  name: hostaliases-pod
spec:
  restartPolicy: Never
  hostAliases:
  - ip: &quot;127.0.0.1&quot;
    hostnames:
    - &quot;foo.local&quot;
    - &quot;bar.local&quot;
  - ip: &quot;10.1.2.3&quot;
    hostnames:
    - &quot;foo.remote&quot;
    - &quot;bar.remote&quot;
  containers:
  - name: cat-hosts
    image: busybox
    command:
    - cat
    args:
    - &quot;/etc/hosts&quot;
</code></pre>
<blockquote>
<p>In addition to the default boilerplate, you can add additional entries to the <code>hosts</code> file. For example: to resolve <code>foo.local</code>, <code>bar.local</code> to <code>127.0.0.1</code> and <code>foo.remote</code>, <code>bar.remote</code> to <code>10.1.2.3</code>, you can configure HostAliases for a Pod under <code>.spec.hostAliases</code>.</p>
</blockquote>
<p>You can find more information about Host Aliases <a href="https://kubernetes.io/docs/tasks/network/customize-hosts-file-for-pods/" rel="nofollow noreferrer">here</a>:</p>
