<p>I have a kubernetes cluster running on GCE.</p>

<p>I created a setup in which I have 2 <em>pods</em> <code>glusterfs-server-1</code> and <code>glusterfs-server-2</code> that are my gluster server.</p>

<p>The 2 <code>glusterfsd</code> daemon correctly communicate and I am able to create replicated volumes, write files to them and see the files correctly replicated on both pods.</p>

<p>I also have 1 <em>service</em> called <code>glusterfs-server</code> that automatically balances the traffic between my 2 glusterfs pods.</p>

<p>From inside another pod, I can issue <code>mount -t glusterfs glusterfs-server:/myvolume /mnt/myvolume</code> and everything works perfectly.</p>

<p>Now, what I really want is being able to use the <code>glusterfs</code> volume type inside my .yaml files when creating a container: </p>

<p><code>...truncated...
    spec:
      volumes:
        - name: myvolume
          glusterfs:
            endpoints: glusterfs-server
            path: myvolume
...truncated...
</code></p>

<p>Unfortunately, this doesn't work. I was able to find out why it doesn't work:</p>

<p>When connecting directly to a kubernetes <em>node</em>, issuing a <code>mount -t glusterfs glusterfs-server:/myvolume /mnt/myvolume</code> does not work, this is because from my node's perspective <code>glusterfs-server</code> does not resolve to any IP address. (That is <code>getent hosts glusterfs-server</code> returns nothing)</p>

<p>And also, due to how glusterfs works, even directly using the service's IP will fail as glusterfs will still eventually try to resolve the name <code>glusterfs-server</code> (and fail).</p>

<p>Now, just for fun and to validate that this is the issue, I edited my node's <code>resolv.conf</code> (by putting my kube-dns IP address and search domains) so that it would correctly resolve my pods and services ip addresses. I then was finally able to successfully issue <code>mount -t glusterfs glusterfs-server:/myvolume /mnt/myvolume</code> on the node. I was then also able to create a pod using a glusterfs volume (using the PodSpec above).</p>

<p>Now, I'm fairly certain modifying my node's <code>resolv.conf</code> is a terrible idea: kubernetes having the notion of namespaces, if 2 services in 2 different namespaces share the same name (say, glusterfs-service), a <code>getent hosts glusterfs-service</code> would resolve to 2 different IPs living in 2 different namespaces.</p>

<p>So my question is:</p>

<p><em>What can I do for my node to be able to resolve my pods/services IP addresses?</em></p>

<p>You can modify <code>resolv.conf</code> and use the full service names to avoid collisions. Usually are like this: <code>service_name.default.svc.cluster.local</code> and <code>service_name.kube-system.svc.cluster.local</code> or whatever namespace is named.</p>
