<p>I am creating two pods with a custom docker image(ubuntu is the base image). I am trying to ping the pods from their terminal. I am able to reach it using the IP address but not the hostname. How to achieve without manually adding <code>/etc/hosts</code> in the pods?</p>
<p>Note: I am not running any services in the node. I am basically trying to setup slurm using this.</p>
<p>Pod Manifest File:</p>
<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: slurmctld
  labels:
    app: slurm
spec:
  nodeName: docker-desktop
  hostname: slurmctld
  containers:
    - name: slurmctld
      image: slurmcontroller
      imagePullPolicy: Always
      ports:
        - containerPort: 6817
      resources:
        requests:
          memory: &quot;1000Mi&quot;
          cpu: &quot;1000m&quot;
        limits:
          memory: &quot;1500Mi&quot;
          cpu: &quot;1500m&quot;  
      command: [ &quot;/bin/bash&quot;, &quot;-c&quot;, &quot;--&quot; ]
      args: [ &quot;while true; do sleep 30; done;&quot; ]
---
apiVersion: v1
kind: Pod
metadata:
  name: worker1
  labels:
    app: slurm
spec:
  nodeName: docker-desktop
  hostname: worker1        
  containers:
    - name: worker1
      image: slurmworker
      imagePullPolicy: Always
      ports:
        - containerPort: 6818
      resources:
        requests:
          memory: &quot;1000Mi&quot;
          cpu: &quot;1000m&quot;
        limits:
          memory: &quot;1500Mi&quot;
          cpu: &quot;1500m&quot;    
      command: [ &quot;/bin/bash&quot;, &quot;-c&quot;, &quot;--&quot; ]
      args: [ &quot;while true; do sleep 30; done;&quot; ]
</code></pre>

Akhil
<p>You can also use <code>hostname -i</code> which in all k8s installs i've tested resolves to the pods IP address.</p>
