<p>My application communicates to some services via hostnames.
When running my application as a docker container i used to add hostnames to the /etc/hosts of the hostmachine and run the container using <code>--net=host</code>. </p>

<p>Now I'm running my containers in kubernetes cluster. I would like to know how can i add the /etc/hosts entries to the pod via <code>yaml</code>.</p>

<p>I'm using kubernetes v1.5.3. </p>

<p>From k8s 1.7 you can add <code>hostAliases</code>. <a href="https://kubernetes.io/docs/concepts/services-networking/add-entries-to-pod-etc-hosts-with-host-aliases/" rel="noreferrer">Example from the docs</a>:</p>

<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: hostaliases-pod
spec:
  restartPolicy: Never
  hostAliases:
  - ip: "127.0.0.1"
    hostnames:
    - "foo.local"
    - "bar.local"
  - ip: "10.1.2.3"
    hostnames:
    - "foo.remote"
    - "bar.remote"
</code></pre>
