<p>I believe my question is pretty straightforward. I'm doing my prerequisites to install Kubernetes cluster on bare metal.</p>

<p>Let's say I have:</p>

<p><strong>master</strong> - hostname for Docker DB container which is fixed on first node</p>

<p><strong>slave</strong> - hostname for Docker DB container which is fixed on second node</p>

<p>Can I communicate with <strong>master</strong> from any container (app, etc.) in a cluster regardless it's running on the same node or not?</p>

<p>Is this a default behaviour?
Or anything additional should be done?</p>

<p>I assume that  I need to setup <code>hostname</code> parameter in YAML or JSON file so Kubernetes is aware what the hostname is.</p>

<p>Probably this is not the factor, but I plan to use Kubespray installation method so it gets Calico networking for k8s.</p>

<p>Many thanks</p>

laimison
<p>Yes,</p>

<p>You can access and communication from any container in a <code>namespace</code> via hostname.</p>

<p>Here is an example about Kubernetes <code>Service</code> configure:</p>

<pre><code>---
apiVersion: v1
kind: Service
metadata:
  name: master
  labels:
    name: master
  namespace: smart-office
spec:
  ports:
  - port: 5672
    name: master
    targetPort: 5672
  selector:
    name: master
</code></pre>

<p><code>Deployment</code> configure:</p>

<pre><code>---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: master
  labels:
    name: master
  namespace: smart-office
spec:
  replicas: 1
  template:
    metadata:
      labels:
        name: master
      annotations:
        prometheus.io/scrape: "false"
    spec:
      containers:
      - name: master
        image: rabbitmq:3.6.8-management
        ports:
        - containerPort: 5672
          name: master
      nodeSelector:
        beta.kubernetes.io/os: linux
</code></pre>

<p>And from other services, for e.g your <code>slaver</code> <code>.env</code> will be:</p>

<pre><code>AMQP_HOST=master &lt;---- The hostname
AMQP_PORT=5672
AMQP_USERNAME=guest
AMQP_PASSWORD=guest
AMQP_HEARTBEAT=60
</code></pre>

<p>It's will work inside Cluster even if you not publish External IP.</p>

<p>Hope this can help you.</p>
