<p>I have configured two services, both as <code>NodePort</code>.</p>

<h1>Service 1</h1>

<pre><code>kind: Service
apiVersion: v1
metadata:
  name: bitcoinrpc-dev-service
  namespace: dev
spec:
  selector:
    app: bitcoin-node
  ports:
  - name: bitcoin-mainnet
    protocol: TCP
    port: 80
    targetPort: 8332
  - name: bitcoin-testnet
    protocol: TCP
    port: 8080
    targetPort: 18332  
  type: NodePort
</code></pre>

<h1>Service 2</h1>

<pre><code>kind: Service
apiVersion: v1
metadata:
  name: counterpartyrpc-dev-service
  namespace: dev
spec:
  selector:
    app: counterparty-node
  ports:
  - name: mainnet
    protocol: TCP
    port: 80
    targetPort: 4000
  - name: testnet
    protocol: TCP
    port: 8080
    targetPort: 14000  
  type: NodePort
</code></pre>

<p>I can access both these services outside the cluster through an ingress. However, when I try to connect to <code>service1(bitcoin</code> from <code>service2(counterparty)</code>, it keeps losing connection. I am referring the service as <code>bitcoinrpc-dev-service.dev.svc.cluster.local:80</code></p>

<p>However, if I refer this service as hostname configured in <code>ingress</code>, the connection is much more stable. e.g. when I refer <code>service1</code> by <code>bitcoin.mydomain.com:80</code></p>

<p>Since, this would mean routing the traffice outside the cluster when both the services that need to communicate to each other are in the same cluster, it seems slightly inefficient.</p>

<p>I tried changing the <code>servicetype</code> to <code>clusterIP</code>, however then I can't access them through ingress.</p>

<p>What should be the correct configuration?</p>

kosta
<p>The reason behind that is only k8s cluster with kube-dns add ons can translate the domain name <code>bitcoinrpc-dev-service.dev.svc.cluster.local:80</code> to its corresponding IP address.</p>

<p>Have a look at this great answer which shows the solutions around this issue:</p>

<blockquote>
  <p><a href="https://stackoverflow.com/questions/47027194/how-to-access-a-service-in-a-kubernetes-cluster-using-the-service-name">How to access a service in a kubernetes cluster using the service name .</a></p>
</blockquote>
