<p>I have a Hyperledger Fabric 1.4 blockchain running under Kubernetes</p>

<pre><code>➜  ~ kubectl get svc -n blockchain
NAME                      TYPE           CLUSTER-IP       EXTERNAL-IP                                                               PORT(S)                           AGE
blockchain-orderer        NodePort       100.68.98.142    &lt;none&gt;                                                                    31010:31010/TCP                   7d4h
blockchain-orderer2       NodePort       100.64.169.137   &lt;none&gt;                                                                    32010:32010/TCP                   7d4h
blockchain-orderer3       NodePort       100.68.185.88    &lt;none&gt;                                                                    31012:31012/TCP                   7d4h
blockchain-org1-ca        NodePort       100.66.249.91    &lt;none&gt;                                                                    30054:30054/TCP                   7d4h
blockchain-org1peer1      NodePort       100.70.28.4      &lt;none&gt;                                                                    30110:30110/TCP,30111:30111/TCP   7d4h
blockchain-org2-ca        NodePort       100.68.243.9     &lt;none&gt;                                                                    30055:30055/TCP                   7d4h
blockchain-org2peer1      NodePort       100.71.114.216   &lt;none&gt;                                                                    30210:30210/TCP,30211:30211/TCP   7d4h
blockchain-org3-ca        NodePort       100.64.199.106   &lt;none&gt;                                                                    30056:30056/TCP                   7d4h
blockchain-org3peer1      NodePort       100.66.55.254    &lt;none&gt;                                                                    30310:30310/TCP,30311:30311/TCP   7d4h
blockchain-org4-ca        NodePort       100.70.219.197   &lt;none&gt;                                                                    30057:30057/TCP                   7d4h
blockchain-org4peer1      NodePort       100.69.141.45    &lt;none&gt;                                                                    30410:30410/TCP,30411:30411/TCP   7d4h
docker                    ClusterIP      100.67.69.23     &lt;none&gt;                                                                    2375/TCP                          7d4h
</code></pre>

<p>What I want is to connect Blockchain remotly from a Go app, and send data to write.</p>

<p>Nevertheless, I don't know how to test connectivity, from what I understand, with a NodePort service, I would be able to connect blockchain statically, via ip:port, as states the <a href="https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types" rel="nofollow noreferrer">docs</a></p>

<blockquote>
  <p>Exposes the Service on each Node’s IP at a static port (the NodePort). A <code>ClusterIP</code> Service, to which the NodePort Service routes, is automatically created. You’ll be able to contact the <code>NodePort</code> Service, from outside the cluster, by requesting <code>&lt;NodeIP&gt;:&lt;NodePort&gt;</code></p>
</blockquote>

<p>My nodes are hosted on AWS. </p>

<p>Pods I must connect are: </p>

<pre><code>blockchain-org1peer1
blockchain-org1peer2
blockchain-org1peer3
</code></pre>

<p>How should I do to be able to connect</p>

Juliatzin
<p>There are multiple solutions I can think of, and others probably have more ideas.</p>

<p>1) Use a load balancer. You can setup a load balancer, or configure an existing one to forward a port to the nodeport of all the worker nodes in your k8s cluster. Then you can call the backend through that load balancer.</p>

<p>2) Use an ingress. The ingress probably already has a load balancer in front of it, and this might be easier to implement. With an ingress, you don't need a NodePort. You can directly connect the pods from the ingress, or add a service in front of each and connect to that service.</p>

<p>You have multiple pods in the backend, and they seem to be peer nodes in the blockchain, not replicas of the same pod. If you need to create three separate endpoints so you can control which peer you connect, an ingress with three proxies connected to these pods would work. </p>

<p>If you do not care which peer you connect, then you can add a service in front of the three pods as a load balancer. You can add a common label to all three peers, and have your service select its destination using that label, so when you hit the service, it acts as a load balancer between the peers. Then you can expose that service via the ingress.</p>
