<p>I just tried setting up kubernetes on my bare server,</p>

<p>Previously I had successfully create my docker compose</p>

<p>There are several apps :</p>

<ul>
<li>Apps A (docker image name : a-service)</li>
<li>Apps B (docker image name : b-service)</li>
</ul>

<p>Inside Application A and B there are configs (actually there are apps A,B,C,D,etc lots of em)</p>

<p>The config file is something like this</p>

<pre><code>IPFORSERVICEA=http://a-service:port-number/path/to/something
IPFORSERVICEB=http://b-service:port-number/path/to/something
</code></pre>

<p>At least above config work in docker compose (the config is inside app level, which require to access another apps). Is there any chance for me to access another Kubernetes Service from another service ? As I am planning to create 1 app inside 1 deployment, and 1 service for each deployment.</p>

<p>Something like:</p>

<pre><code>App -&gt; Deployment -&gt; Service(i.e: NodePort,ClusterIP)
</code></pre>

<p>Thanks !</p>

thegexploit
<blockquote>
  <p>Is there any chance for me to access another Kubernetes Service from
  another service ?</p>
</blockquote>

<p>Yes, you just need to specify DNS name of service (<code>type: ClusterIP</code> works fine for this) you need to connect to as:</p>

<pre><code>&lt;service_name&gt;.&lt;namespace&gt;.svc.cluster.local
</code></pre>

<p>In this case such domain name will be correctly resolved into internal IP address of the service you need to connect to using built-in DNS.</p>

<p>For example:</p>

<pre><code>nginx-service.web.svc.cluster.local
</code></pre>

<p>where <code>nginx-service</code> - name of your service and <code>web</code> - is apps's namespace, so service yml definition can look like:</p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: nginx-service
  namespace: web
spec:
  ports:
  - name: http
    protocol: TCP
    port: 80
  selector:
    app: nginx
  type: ClusterIP
</code></pre>

<p>See <a href="https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/#services" rel="nofollow noreferrer">official docs</a> to get more information.</p>
