<p>I have a pod created on the local machine.  I also have a script file on the local machine.  I want to run that script file from the pod (I will be inside the pod and run the script present on the local host).</p>

<p>That script will update <code>/etc/hosts</code> of another pod.  Is there a way where i can update the <code>/etc/hosts</code> of one pod from another pod?  The pods are created from two different deployments.</p>

jaya rohith
<blockquote>
  <p>I want to run that script file from the pod (I will be inside the pod and run the script present on the local host).</p>
</blockquote>

<p>You can't do that.  In a plain Docker context, one of Docker's key benefits is filesystem isolation, so the container can't see the host's filesystem at all unless parts of it are explicitly published into the container.  In Kubernetes not only is there this restriction, but you also have limited control over which node you're running on, and there's potential trouble if one node has a given script and another doesn't.</p>

<blockquote>
  <p>Is there a way where i can update the <code>/etc/hosts</code> of one pod from another pod?</p>
</blockquote>

<p>As a general rule, you should avoid using <code>/etc/hosts</code> for anything.  Setting up a DNS service keeps things consistent and avoids having to manually edit files in a bunch of places.</p>

<p>Kubernetes provides a DNS service for you.  In particular, if you <a href="https://kubernetes.io/docs/concepts/services-networking/service/" rel="nofollow noreferrer">define a Service</a>, then <a href="https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/" rel="nofollow noreferrer">the name of that Service will be visible as a DNS name</a> (within the cluster); one pod can reach the other via <code>first-service-name.default.svc.cluster.local</code>.  That's probably the answer you're actually looking for.</p>

<p>(If you really only have a single-node environment then Kubernetes adds a lot of complexity and not much benefit; consider plain Docker and Docker Compose instead.)</p>
